Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule conflict with RedirectPermanent

         

omoutop

1:19 pm on Mar 1, 2006 (gmt 0)

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



Hello all..

In my .htaccess file i have a set of rules like this one like

RewriteRule ^([^/]+)/([^/]+)/hotels/([^-]+)-([^-]+)\.htm$ some_folder/php_page.php?var1=$1&var2=$2&var3=$3&tvar4=$4 [NC,L]

and another set of rules like

RedirectPermanent /folder1/folder2/hotels/name1-hotel.htm [mysite.com...]

a) if i have only php pages in site, first rules works ok
b) if i have only htm pages in site, second rules works fine
c) when i combie the two rules (meaning i have php and htm files in site, I face a problem...

from second rules i get the correct page but in the following format..

[mysite.com...]

It seems as thought the two rules are merged into one.. the part up to .htm (comes from second rule) its correct), while the part after?var1= (comes from firest rule) is also correct, but I dont want it to appear on url.

This problem comes when i try to use second rule in pages that "dont exist" (they are created by the first rule). I am in the proccess of changing a static site into a dynamic one.

Any advice?

jdMorgan

2:30 pm on Mar 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to use mod_rewrite for both the internal rewrite and the external redirect, instead of using mod_rewrite for one and mod_alias for the other; Otherwise, you cannot control execution order or precedence. Currently, the internal rewrite is being done, followed by the external redirect. The redirect therefore 'exposes' your internal rewrite.

Re-code the Redirect directive as a RewriteRule, use the [L] flag, and place it before the internal rewrite rule.

Jim

omoutop

7:05 am on Mar 2, 2006 (gmt 0)

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



Thanks for the tip JD but it didn't help. I finally track the problem to a set of 7 creation rules (no way to change them since the reproduce the product pages in same pattern as they were in plaint htm pages).

Temp solution i got (and working) is by making seperate htaccess files in specific folders with full set of creation/redirection rules.

I understand that this method overloads the server, but it will have to do for 2-3 months untill site is fully dynamic and there is no need to redirect "illusionary" pages anymore

Thanks again for advice