Forum Moderators: phranque

Message Too Old, No Replies

Rewriterule with url parameters

         

nirfun

5:36 pm on Mar 28, 2009 (gmt 0)

10+ Year Member



Hi,

I need to create a rewrite rule and I need some help.
I want that:

modules.php?name=News&file=article&sid={somenumber}
=> article{somenumber}.html

Help?
Thanks.

g1smd

5:40 pm on Mar 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A rewrite does not 'make' a URL.

If you want to have a new URL, then you need to link to that URL from the pages of your site.

The rewrite connects those URL requests with the real server-internal filepath where the file really resides, without revealing what internal location actually is.

This topic comes up almost every day here. What code have you tried so far?

nirfun

5:45 pm on Mar 28, 2009 (gmt 0)

10+ Year Member



I know that.
I have erased a line from my htacess and now many links are broken.

When someone goes to "article{somenumber}.html", apache should go to "modules.php?name=News&file=article&sid={somenumber}"

thanks

nirfun

5:48 pm on Mar 28, 2009 (gmt 0)

10+ Year Member



Problem solved:
RewriteRule ^article([0-9]+)\.html modules.php?name=News&file=article&sid=$1 [L]

Thanks!

g1smd

5:51 pm on Mar 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That looks good.

Try accessing you new URL at both www and non-www versions of your URL.

What happens?

One should work. The other should redirect to the URL that works, not directly serve content at that second URL.

jdMorgan

5:51 pm on Mar 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is simple enough that you should have had no trouble at all trying to code it...

RewriteRule ^article([0-9]+)\.html$ /modules.php?name=News&file=article&sid=$1 [L]

Jim