vendredi 3 avril 2015

How to redirect properly using htaccess?


Vote count:

0




I'm trying to redirect with rewrite rules in Apache - .htaccess. I had set of rules which worked fine for redirection all http:// to https://.


So if the user try http://ift.tt/19QQet6, http://example-old.com, http://ift.tt/1apU0uh or http://example-new.com, all of this will be redirected to https://example-new.com


Now I want to add one more address on the server which I do NOT want to be redirected to https://example-new.com


So I want it to be excluded from the code below. If somebody try http://ift.tt/19QQet8 it should redirect to it properly.



RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [OR,NC]
RewriteCond %{HTTP_HOST} ^example-old\.com$ [NC]
RewriteRule ^ https://example-new.com%{REQUEST_URI} [L,R=301]


What I tried in addition to the code above is:



RewriteCond %{HTTP_HOST} ^newest-example\.com$ [NC]
RewriteRule ^ http://ift.tt/19QQet8 [R=301,S=1]


This code is above the first block I presented. Like you can see I tried to skip original RewriteRule with S=1 if URL is http://ift.tt/19QQet8 but that gives me this message:



Moved Permanently

The document has moved here.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.


Not that experienced with this and I'm not sure what I'm missing here. Thanks in advance.



asked 44 secs ago







How to redirect properly using htaccess?

Aucun commentaire:

Enregistrer un commentaire