Forum Moderators: phranque

Message Too Old, No Replies

htaccess question

         

darkwind

10:11 am on Sep 4, 2011 (gmt 0)

10+ Year Member



Hello,

I have these 2 files in the same directory
file1.php
file2.php

I'm using the htaccess rules below:

RewriteRule pagename/ file1.php
RewriteRule one/two/pagename/ file2.php


The redirection for the first file, file1.php works fine but accessing the redirection URL for file2.php shows the content of file1.php.

Any help would be appreciated.

g1smd

11:03 am on Sep 4, 2011 (gmt 0)

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



RewriteRule pagename/ file1.php


With no anchoring the RegEx pattern says "rewrite any request that contains
pagename/
so it matches the other requested URL too.

Add the [L] flag to every rule.

Add ^ anchoring to say begins with instead of contains.

Change the order of the rules so that rules which are more specific and affect the least number of URLs are first, and the more general rules are last.

Add your non-www to www redirect rule before these rewrites.

darkwind

11:23 am on Sep 4, 2011 (gmt 0)

10+ Year Member



Wow.

Worked like a charm.

Thanks a lot!

g1smd

11:42 am on Sep 4, 2011 (gmt 0)

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



Post your final code in case there are other issues to fix.