Forum Moderators: phranque

Message Too Old, No Replies

php does not work but html does in .htaccess

I can rewrite a file to html but not php at the site root level?

         

mlong

8:41 am on Nov 14, 2008 (gmt 0)

10+ Year Member



This may be a simple quesiton but I'm new to this. I cna not get a php file to rewrite to another php url. We have to maintain the same site structure. Does anyone know how to fix this.

This does not work:

RewriteRule ^(.+).php$ /template_prod.php?load_prod=$1 [NC,L]

This does work:

RewriteRule ^(.+).html$ /template_prod.php?load_prod=$1 [NC,L]

Can someone tell me why and how to rewrite to a URL that ends in php at the root level?

g1smd

2:01 pm on Nov 14, 2008 (gmt 0)

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



You have an infinite loop.

Rewrite any .php URL request to the new filepath.

Rewrite any .php request (which matches the updated internal information for the new path) to the new filepath.

Rewrite any .php request (which matches the updated internal information for the new path) to the new filepath.

... loops forever or until the browser or server gives up ...

You need a RewriteCond in front of the Rule to check that the URL is coming directly from THE_REQUEST and not as a result of a previous rewrite.

jdMorgan

2:04 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or simply prevent that php file from being rewritten to itself:

RewriteCond $1 !^template_prod$
RewriteRule ^(.+)\.php$ /template_prod.php?load_prod=$1 [NC,L]

Jim