Contrast Web Contrast Web -4 years ago 107
Apache Configuration Question

What did I do wrong with my 301 redirects?

I'm working on a domain www.centreauto.ca which is getting redirected to www.autoevolution95.com.

I have written a bunch of rewrite rules in centreauto.ca's .htaccess file:

# Use PHP5.4 as default
#AddHandler application/x-httpd-php54s .php

# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymlinks
Options +SymLinksIfOwnerMatch

# Prevent Directoy listing
Options -Indexes

# SEO URL Settings
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^([^?]*) action.php?route=$1 [L,QSA]

Redirect 301 / http://www.autoevolution95.com/
Redirect 301 /?lang=french http://www.autoevolution95.com/
Redirect 301 /?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /index.php http://www.autoevolution95.com/
Redirect 301 /index.php?lang=french http://www.autoevolution95.com/
Redirect 301 /index.php?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales http://www.autoevolution95.com/
Redirect 301 /car-sales?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/carfax http://www.autoevolution95.com/
Redirect 301 /car-sales/carfax?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/carfax?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/credit-application http://www.autoevolution95.com/
Redirect 301 /car-sales/credit-application?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/credit-application?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/financing http://www.autoevolution95.com/
Redirect 301 /car-sales/financing?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/financing?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/inspections http://www.autoevolution95.com/
Redirect 301 /car-sales/inspections?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/inspections?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/warranties http://www.autoevolution95.com/
Redirect 301 /car-sales/warranties?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/warranties?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/we-buy http://www.autoevolution95.com/
Redirect 301 /car-sales/we-buy?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/we-buy?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /car-sales/why-centre-auto http://www.autoevolution95.com/
Redirect 301 /car-sales/why-centre-auto?lang=french http://www.autoevolution95.com/
Redirect 301 /car-sales/why-centre-auto?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work http://www.autoevolution95.com/
Redirect 301 /body-work?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work/got-into-an-accident http://www.autoevolution95.com/
Redirect 301 /body-work/got-into-an-accident?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work/got-into-an-accident?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work/insurance-claim http://www.autoevolution95.com/
Redirect 301 /body-work/insurance-claim?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work/insurance-claim?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work/body-repair http://www.autoevolution95.com/
Redirect 301 /body-work/body-repair?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work/body-repair?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work/guarantee http://www.autoevolution95.com/
Redirect 301 /body-work/guarantee?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work/guarantee?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-work/book-body-work-appointment http://www.autoevolution95.com/
Redirect 301 /body-work/book-body-work-appointment?lang=french http://www.autoevolution95.com/
Redirect 301 /body-work/book-body-work-appointment?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /mechanics http://www.autoevolution95.com/
Redirect 301 /mechanics?lang=french http://www.autoevolution95.com/
Redirect 301 /mechanics?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /mechanics/auto-repair http://www.autoevolution95.com/
Redirect 301 /mechanics/auto-repair?lang=french http://www.autoevolution95.com/
Redirect 301 /mechanics/auto-repair?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /mechanics/maintenance http://www.autoevolution95.com/
Redirect 301 /mechanics/maintenance?lang=french http://www.autoevolution95.com/
Redirect 301 /mechanics/maintenance?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /mechanics/book-mechanical-repair-appointment http://www.autoevolution95.com/
Redirect 301 /mechanics/book-mechanical-repair-appointment?lang=french http://www.autoevolution95.com/
Redirect 301 /mechanics/book-mechanical-repair-appointment?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /company/promotions http://www.autoevolution95.com/
Redirect 301 /company/promotions?lang=french http://www.autoevolution95.com/
Redirect 301 /company/promotions?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /company http://www.autoevolution95.com/
Redirect 301 /company?lang=french http://www.autoevolution95.com/
Redirect 301 /company?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /company/contact-us http://www.autoevolution95.com/
Redirect 301 /company/contact-us?lang=french http://www.autoevolution95.com/
Redirect 301 /company/contact-us?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /got-into-an-accident http://www.autoevolution95.com/
Redirect 301 /got-into-an-accident?lang=french http://www.autoevolution95.com/
Redirect 301 /got-into-an-accident?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /insurance-claim http://www.autoevolution95.com/
Redirect 301 /insurance-claim?lang=french http://www.autoevolution95.com/
Redirect 301 /insurance-claim?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /body-repair http://www.autoevolution95.com/
Redirect 301 /body-repair?lang=french http://www.autoevolution95.com/
Redirect 301 /body-repair?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /guarantee http://www.autoevolution95.com/
Redirect 301 /guarantee?lang=french http://www.autoevolution95.com/
Redirect 301 /guarantee?lang=english http://www.autoevolution95.com/?lang=en

Redirect 301 /brochures/garanties-supplementaires-vehicules-automobiles.pdf http://www.autoevolution95.com/
Redirect 301 /brochures/garanties-supplementaires-vehicules-automobiles_en.pdf http://www.autoevolution95.com/?lang=en

Redirect 301 /sitemap http://www.autoevolution95.com/sitemap.xml
Redirect 301 /sitemap?lang=french http://www.autoevolution95.com/sitemap.xml
Redirect 301 /sitemap?lang=english http://www.autoevolution95.com/sitemap.xml





However If you now navigate to one of the pages that were supposed to get redirected properly, they erroneously get redirected to the wrong path, i.e.:

http://www.centreauto.ca/car-sales?lang=english

doesn't redirect to:

http://www.autoevolution95.com/?lang=en

Any recommendations on what's being done wrong? Can it be that the url rewrites on autoevolution95.com are done incorrectly?

Here's a sample of them:

urlpatterns += patterns('',
url(r'^$', DKIObjectsView.as_view(
template_name="addon-sites/autoevolution95/main-site/pages/index.html",
relevance_json = silos_keywords_json)),


Thanks,

Michal

Answer Source

301 redirects in the .htaccess file are literal.

Redirect 301 /insurance-claim http://www.autoevolution95.com/ means redirect /insurance-claim to http://www.autoevolution95.com/

So if you want to redirect to the same url at the new domain, you have to add it in the redirection rule:

Redirect 301 /insurance-claim http://www.autoevolution95.com/insurance-claim

A better solution might be to come up with a rewrite rule that redirects everything from the old domain to the new domain.

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ http://autoevolution95.com/$1 [R=301,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download