Jump to content

Rewrite Help


drath

Recommended Posts

I'm trying to change the following:

http://www.sitename.com/page.php?id=pagename

http://www.sitename.com/page.php?id=otherpagename

 

to:

 

http://www.sitename.com/pagename.php

http://www.sitename.com/otherpagename.php

 

I tried the following:

RewriteRule ^/(.*)\.php$ /page.php?id=$1 (no effect)

RewriteRule ^(.*)\.php$ /page.php?id=$1 (500/404)

 

Anybody see my error(s)?

 

Link to comment
https://forums.phpfreaks.com/topic/187905-rewrite-help/
Share on other sites

The problem is that it's looping infinitely.

 

RewriteRule ^(.*)\.php$ /page.php?id=$1 (500/404)

 

With RewriteRule, only the page name is compared, not the query string too (in other words, only /path/page.php, not /path/page.php?blah=bleh).

 

AS such, RewriteRule ^(.*)\.php$ matches page.php....

 

So, it goes into an infinite loop.

 

Try something like:

 

 

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)\.php$ /page.php?id=$1

Link to comment
https://forums.phpfreaks.com/topic/187905-rewrite-help/#findComment-992218
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.