0

I have my .htaccess set up to rewrite 'friendly URLs' - the first is working perfectly and rewrites as it should, however the second, which is written in exactly the same way does not work and results in a 404. I'm not sure where I'm going wrong.

The following rewrites correctly to mysite.com/1:

# Setup conditions for internal rewrite of DYHAMB
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite for DYHAMB
RewriteRule ^(0|[1-9]\d{0,2})$ /episode.php?episode=$1&podcast=DYHAMB [L,QSA]
# External redirect for DYHAMB
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+episode\.php\?episode=(\d+)\&podcast\=DYHAMB [NC]
RewriteRule ^ /%1? [R=301,L]

However this should rewrite to mysite.com/new/1 but actually returns 404:

# Setup conditions for internal rewrite of new
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite for new
RewriteRule ^(0|[1-9]\d{0,2})$ /episode.php?episode=$1&podcast=new [L,QSA]
# External redirect for new
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+episode\.php\?episode=(\d+)\&podcast\=new [NC]
RewriteRule ^ /new/%1? [R=301,L]
4

1 回答 1

0

您需要匹配重定向 URI 的“新”部分:

RewriteRule ^new/(0|[1-9]\d{0,2})$ /episode.php?episode=$1&podcast=new [L,QSA]
于 2012-08-04T11:44:34.610 回答