views:

12

answers:

1

In my htaccess I have a rule -

I have this rule

RewriteRule ^mk$ http://mysite.com/mypage.php [r=301,nc]

and later on :

RewriteCond %{HTTP_HOST} !^mysite\.com$ [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [QSA,L,R=301]

This works fine for http://mysite.com/mk
- it redirects to: http://mysite.com/mypage.php as I wanted.

...but when I go to http://www.mysite.com/mk it redirects to http://mysite.com/http://mysite.com/mypage.php

Are these 2 rules incompatable? Can anyone tell me what's happening and what to do?

Thanks

A: 

They are compatible, but in your case I think order matters. I would move the host redirect above the mk redirect and try again.

Another thing would be to add the L flag (Last) to the mk rule. This should trigger the redirect immediately.

I am not sure if you have any other rules that you want to run first. So see what the order does if that matters to you. Essentially these rules are pairing up and double rewriting http://www.mysite.com/mk

Jason McCreary
Swapping the order sorted it out... thanks very much!
iKode