Reputation: 7679
So I'm building a new site and everything at the old site is going to be scrapped - including the domain structure, and domain name. I currently have a redirect rule in my .htaccess setup to redirect http://jagdesignideas.com to http://jag.is as such:
RewriteCond %{HTTP_HOST} ^(www.)?jagdesignideas.com
RewriteRule ^(/)?$ "http://jag.is" [R=301,L]
But the trouble is if a user follows a link from elsewhere on the intarwebz to http://jagdesignideas.com/about, for example, that does not redirect to http://jag.is as I would like. Instead it brings up the 404 page from the jagdesignideas.com domain.
How to I get all substrings of jagdesignideas.com domain to endup at the new redirect?
EDIT: To be clear, I'm not trying to match pages on the old site to the new site, only do a mass redirect of jagdesignideas.com and anything there just to point at the jag.is domain.
Upvotes: 0
Views: 376
Reputation: 3413
The isse us what you are matching in your RewriteRule: ^(/)?$
matches the root slash or nothing, which means you are only rewriting calls to your domain root. You need to capture all path components instead, using ^.*$
, which matches anything after the domain root, or nothing. This will redirect any call to your old domain, with or without a path, to the root of your new domain:
RewriteCond %{HTTP_HOST} ^(www\.)?jagdesignideas\.com [NC]
RewriteRule ^.*$ http://jag.is [R=301,L]
If you want to redirect your path structure to an identical one on your new server, this will do the trick:
RewriteRule ^.*$ http://jag.is/$0 [R=301,L]
Starting from there, you can basically do any kind of redirect to map old to new path structures – see the Apache Module mod_rewrite reference.
Upvotes: 1