user4759415
user4759415

Reputation:

301 Re-direct w/ .htaccess

I'm writing 301 re-directs and no matter whether I do the redirect in .htaccess or as a meta, javascript redirect they all work but append the old url or directory onto the end of the redirected url.

This is what i have in .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.bigcars.ca [NC]
RewriteRule ^(.*)$ http://support.ca/$1 [L,R=301]

redirect 301 /contact http://support.ca/mynewpage/pagename.html?somequeries
redirect 301 /contact.html http://support.ca/mynewpage/pagename.html?somequeries

In addition to that i've tried going to the contact.html page that i want to redirect and putting in a meta and/or javascript (both worked but kept /contact on the end) but neither one fully gave me what i wanted.

Each method is consistently doing the redirect but i'm always left with /contact or contact.html at the end of my URL

Help?

Upvotes: 0

Views: 38

Answers (1)

anubhava
anubhava

Reputation: 785471

You must not mix Redirect directive with mod_rewrite directives. You can use:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?bigcars\.ca$ [NC]
RewriteRule ^(.*)$ http://support.ca/$1 [L,R=301]

RewriteRule ^contact(?:\.html)?/?$ http://support.ca/mynewpage/pagename.html?somequeries [L,NC,R=301]

Upvotes: 1

Related Questions