PDA

View Full Version : another rewrite problem


mndasher
06-21-2009, 05:40 AM
In my .htaccess file I have several rewrites going on. I tried adding a new one today, and got an odd error.

"Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

The new rewrite rule looks like this.


RewriteRule ^([A-Za-z]+)/([0-9]+)/([A-Za-z0-9-]+)\.html$ /index.php?article=$2&title=$3 [L,nc]


The input url should look like
http://www.mywebsite.com/article/5/some-title.html

and redirect to

http://www.mywebsite.com/index.php?article=5&title=some-title


I tried having the first part of the rewrite rule be explicitly ^(article)/ but that didn't work either. The /article/ just means it is an article I want and is other wise a throw away. I have also tried having the $2 and $3 be $1 and $2 but that didn't work either.

The other rewrites are this;

RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,nc]
RewriteRule ^([0-9]+)/([a-zA-Z0-9-]+)\.html$ /index.php?id=$1&title=$2 [L,nc]
RewriteRule ^([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)\.html$ /index.php?id=$1&mo=$2&title=$3 [L,nc]
RewriteRule ^([0-9]+)/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)\.html$ /index.php?id=$1&mo=$2&exp=$3&title=$4 [L,nc]

Without the new rewrite these all function correctly.

mndasher
06-22-2009, 10:38 PM
Didn't resolve the problem directly. But I made use of one of the other rewrites, and modified what the rewrite input looks like.

now I input http://www.mywebsite.com/20090622123/some-title.html

Out comes index.php?id=20090622123&title=some-title.html


In index.php I test to see if the id field is at least nine char in length, and if it is, I strip off the leading 8 characters and use the remainder as $articleID, and process as I wish. This seems to be working pretty well, and eliminated the need for another rewrite rule.

In this case $articleID =123