Forum Moderators: phranque

Message Too Old, No Replies

Help with a rewrite rule please

         

bramley

1:51 am on Apr 23, 2011 (gmt 0)

10+ Year Member



I am in a situation where the first directory is sometimes erroneously repeated and I need to fix this in .htaccess but my rule, though it looks correct, does not seem to work.

domain.com/beijing/beijing/index.php?do=a

should be :

domain.com/beijing/index.php?do=a

RewriteRule ^beijing/beijing/index.php /beijing/index.php [R,L]

- tia

bramley

3:00 am on Apr 23, 2011 (gmt 0)

10+ Year Member



Also tried :

RewriteRule ^beijing/(.*)+/index.php [domain.com...] [R,L]

But nothing seems to work when have a repeated directory name :(

bramley

3:13 am on Apr 23, 2011 (gmt 0)

10+ Year Member



RewriteRule ^beijing/([^/]+/)+index.php [domain.com...] [R,L]

Also doesn't work :(

bramley

3:14 am on Apr 23, 2011 (gmt 0)

10+ Year Member



Finally solved :)

g1smd

8:07 am on Apr 23, 2011 (gmt 0)

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



How did you solve it?

Your code is for a 302 redirect. Change R to R=301.

The URL you redirect to, should NOT include the "index.php" part.

Add "DirectoryIndex index.php" to your configuration file.

Use example.com to stop the forum auto-linking the URL.