view raw
Jason Schot Jason Schot - 8 months ago 36
Apache Configuration Question

Redirect all pages from old domain to new specific URL without trailing slash content

I've got an old domain, let's say where I need to redirect all traffic to a specific URL,

While redirects from go perfectly, anything with content after the trailing slash will be copied over in the newdomain url structure causing 404's.

For example visiting: will result in

What I'm looking for are some rewrite rules that will redirect any and all traffic from to without changing the specific "" URL.

I'm currently using the rules bellow which leads to the result above:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*) [P]

PS: the redirect is going to a Magento store.


You are trying to reverse-proxy in your directives (the P flag in the rewrite), but since you are describing a redirect... In the old virtualhost you just need to add a simple Redirect directive like this:

Redirect /

This will Redirect all requests no matter how they are made to the new domain. Example GET /something will be redirected to

If you want the target to be a fixed destination like no matter what, use RedirectMatch instead:

RedirectMatch ^