Rewriting my rewrite?

Oh, the strange things mod_rewrite does!

Rewriting my rewrite?

Postby akirablaid » Thu Feb 28, 2008 12:16 pm

Here's my code
Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([a-z]+).php$ letter.php?alpha=$1 [NC]


And here's the page
http://yellow.nothingtoprove.net/b.php

When you go to b.php it displays
letter.php?alpha=b
But then, it seems to be rewriting that, so it becomes
letter.php?alpha=letter
and THEN displays the page. That seems to be why it's trying to include include_cat_letter.txt instead of include_cat_b.txt

I need to fix this asap!
akirablaid
 
Posts: 1
Joined: Thu Feb 28, 2008 12:12 pm

Postby richardk » Fri Feb 29, 2008 12:56 pm

^([a-z]+).php$ matches letter.php. When letter.php?alpha=b is requested mod_rewrite is processed again (up to MaxRedirects or an 500 Internal Server Error).
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Don't match sub requests.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^([a-z]+)\.php$ letter.php?alpha=$1 [NC,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 2 guests

cron