L01C
L01C

Reputation: 753

RewriteRule override Redirect 301

I'd like to put two rules in my .htaccess. First priority, manual redirections. Then, every others URLs are redirect to another domain.

My .htaccess works when I use only the "redirect" or when I use only the "rewriterule", but when I use both, the rewriteRule override "redirect" and I can't choose to redirect some URLs manually. However the redirect line is higher in the code so I think it should be the priority.

My .htaccess:

Redirect 301 /directory/redirectiontest/pagebase1.php http://v2.mywebsite.com/nous-contacter.html
Redirect 301 /directory/redirectiontest/pagebase2.php http://v2.mywebsite.com/nous-contacter.html

RewriteEngine on
RewriteRule ^(.*)$ https://v2.mywebsite.com/$1 [R=301,L]

Thanks for help :-).

Upvotes: 1

Views: 1139

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

Your RewriteRule is overriding your Redirects because you have mixed Redirect with RewriteRule . Theses directives are part of two different Apache modules and have different runtime behaviour. Use RewriteRule for your manual url redirection.

 RewriteEngine on
 RewriteRule ^/?directory/redirectiontest/pagebase1.php http://v2.mywebsite.com/nous-contacter.html [L,R]
 RewriteRule ^/?directory/redirectiontest/pagebase2.php http://v2.mywebsite.com/nous-contacter.html [L,R]


RewriteRule ^(.*)$ https://v2.mywebsite.com/$1 [R=301,L]

Upvotes: 0

Related Questions