I have a website say domain.old hosted with say 'host-old'
I want to do away with 'host-old' and go with 'host-new'
(so effectively 'host-old' hosting would end)
Also I want a new domain - say 'domain.new'
So now I have 'domain.old' , 'domain.new' and 'host-new' with me
Now I want all my old links are preserved:
viz. http://domain.old/cat1/link1/page1/
redirects to http://domain.new/cat1/link1/page1/
Now please advice what would be the best way to go to set up with the new host.
This is a multi-step process:
Create all the pages at 'host-new' so that 'http://domain.new/cat1/link1/page1/' all work.
Enable mod_rewrite in Apache on 'host-new', and configure as below.
Change the dns entries for 'domain.old' to point to 'host.new'
wait 2-3 days for dns entries to propagate to remainder of the internet.
stop hosting at 'host-old'
The mod_rewrite config you need is:
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.old$
RewriteRule ^(.*)$ http://domain.new/$1 [NE,R=301,L]
i don't know exactly how this would work but you could parse the URL from the old site and redirect to your new host. You need a common script in your domain.old masterpage that does this for you.
The question would be easier to answer if you specified your platform. If you are on Apache, I'd take a look at mod_rewrite
You'll probably want to provide a 301 (moved permanently) http response.
When you get rid of the old domain, you can't control it any more, and therefore won't get traffic from it. You should transfer the old domain to your new host (not too hard), and then have a redirector running on it - the way other answers suggest.
Related
I'm migrating a blog installation to a new server. The original installation was on an Amazon server. The new server location will be the true server that the Amazon install was made to appear at through some DNS changes and a Cname alias.
The aliased URLs looked like this...
blog.domain.tld/articles/{title of articles}
At the new and true domain location, the false "blog" aliasing will be dropped, and the new URL structure will be...
domain.tld/articles/{title of articles}
I need to setup some mod_rewrite rules so that calls to the old fake URLs will land people at the new and true ones. I've seen good examples online of root-to-subdirectory or subdirectory-to-root redirects on the same server, but in this case where the faux subdirectory was involved on a different server, I'm not sure what to do. I'm not even sure it makes sense (or is possible) to redirect from an aliased URL.
Anyone have any pointers, insights, or examples? Thanks in advance.
This is very similar to just redirecting www. links to non-www links, so the following should work:
RewriteCond %{HTTP_HOST} ^blog\.domain\.tld$
RewriteRule (.*) http://domain.tld/$1 [R=301,L]
I had to redesign a site last week. The problem is that last urls weren't seo friendly so, in order to avoid Google penalizing my site because too many 404 errors, I have to create a lot of Rewrite Rules because all the content had awful URL's ( and that content had a good position on SERP's).
For example:
RewriteRule ^documents/documents_for_subject/22-ecuaciones-exponenciales-y-logaritmicas http://%{HTTP_HOST}/1o-bachillerato/matematicas-cc.ss/aritmetica-y-algebra/ecuaciones-exponenciales-y-logaritmicas [R=301,L]
Is this a problem on my performance? Is there another solution to my situation?
Thanks
They are in the same domain.
Then an internal redirect is much better. A header redirect sends the new URL to the browser and causes it to make a new request; an internal one is handled, as the name says, internally.
This should work:
RewriteRule ^documents/documents_for_subject/22-ecuaciones-exponenciales-y-logaritmicas /1o-bachillerato/matematicas-cc.ss/aritmetica-y-algebra/ecuaciones-exponenciales-y-logaritmicas [L]
Any performance issues are going to be negligible with this - except maybe if you have many thousands or tens of thousands of individual rules, those may slow down Apache. In that case, if you have access to the central server configuration, put the rules there instead of a .htaccess file, because instructions in the server config get stored in memory and are faster.
A. Yes using 301 is the right way to notify search bots about changed URLs and eventually your old URL's will be removed from search results.
B. You don't need to use %{HTTP_HOST} in your rewrite rule just use it like this:
RewriteRule ^documents/documents_for_subject/22-ecuaciones-exponenciales-y-logaritmicas http://%{HTTP_HOST}/1o-bachillerato/matematicas-cc.ss/aritmetica-y-algebra/ecuaciones-exponenciales-y-logaritmicas [R=301,L]
C. If you have lots of RewriteRules like above I recommend using RewriteMap or else use some scripting support (like PHP) to redirect from old to new URL with 301.
We're moving a fairly large website from domain.one where it's been for a long time onto domain.two. If people still find links for domain.one we want them to redirect to an appropriate place on domain.two (if possible).
Domian.one is no longer required after the switch. I don't know anything about moving an entire domain so could use some advice on the best way to go about switching whilst retaining the SEO gained over the years.
Any help is appreciated.
Many thanks
Put this in an htaccess file in your root web directory. It will forward your users, and search engines, to the new URL on the new domain.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
ADD THE FOLLOWING LINES as posted by John .
Also log in to google webmaster tools->configuration->change of address
and change your url ther so that seacrh engine results are also changed.
THIS iS VERY IMPORTANT
I'm working on a website (say, www.domain.com) and want to release part of the site (say, www.domain.com/foo/). How do I forcibly redirect users via .htaccess? Are there any SEO concerns about this? Would it be better if I just modified my application so that the part that is ready is accessible in the root domain?
This will redirect anything to the location of your choice. (.*) matches 0 or more of any char.
RewriteRule ^(.*)$ foo/ [flags]
SEO implications, I'm not certain of, but if you're only ready to release some parts of the site, then there's no issue there as the crawler will get the links you want it to. I'd advise sticking with the .htaccess solution instead of doing any modification as it leaves you free to add or change things more easily at a later stage.
i have a site like twitter.com on server one and on server two i have forum, which path is like domain.com/forum
on server one i wanted to implement wild card dns and put main domain on it. but on server two i wanted to keep forum separate, i cant give sub-domain forum.domain.com, because all its links are already put in search engines and link back to domain.com/forum.
so i was wondering, how can i put domain and wild card dns on server one and still able to give path on server 2 for domain.com/forum (as sub-folder).
any ideas?
do you think htaccess can do that job? if yes, then how?
You could use htaccess and mod_rewrite so domain.com/forum actually displays pages from forum.domain.com.
Maybe something like this:
Options +FollowSymLinks
RewriteEngine on
RewriteRule domain.com/forum/(.+) forum.domain.com/$1
Easy - use a proxy! If you like apache you will love apache mod_proxy for your purpose.
<VirtualHost *:80>
ServerName maindomain.com
ServerAlias *.maindomain.com
# insert document root and general settings for this domain here
# ...
ProxyPass /forum http://forumdomain.com
ProxyPassReverse /forum http://forumdomain.com
ProxyPassReverseCookieDomain forumdomain.com maindomain.com
</VirtualHost>
This configuration makes apache do a HTTP-request to your internal domain (forumdomain.com) without notifiying the users browser of the internal location. Your Forum will be accessable at http://*.yourdomain.com/forum. Cookies and headers the forum sents will get rewritten accordingly and Search-engines will not take notice of your backend-server.
You can read more about it at http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Should you need to rewrite reference sin your html (href, src ...) you might google on "mod_proxy_html".
A solution like this could of course be build with other intelligent proxyservers like squid as well. You can use it to map any content from "backend servers" to your public domain.
Make sure routing is OK or set up a host-entry for your internal domain (forumdomain) with a internet ip-addresse 192.168 ...
Enjoy your site and give feedback how worked out :)
p.s.: a "RewriteRule" directive can potentially do the same thing for you but the rdirect will be visible (and executed) by the client unless you specify the "P", foricng it to do an internal proxy request. If available I would prefer the mod_proxy though as it is more versatile and allows for more configuration.
If you use a proxy on server 1 pointing to server2, you will increase the load on server 1, since all traffic will be routed through it. Besides, if server 1 goes down, nobody will be able to reach server 2 either. Of course it is possible though, but these things are to be considered.
I would suggest setting up a supdomain for server 2 anyway, like forum.domain.com, and on server 1 you set up a 301 redirect from domain.com/forum to forum.domain.com using mod_rewrite from htaccess. Using that technique, you can even redirect calls to specific links to their corresponding page on server 2. Search engines will follow the 301 and they will eventually update the index.
You can use a 301 redirect to make sure the search engine update their index with your new urls like so:
RewriteRule domain.com/forum/(.*) http://forum.domain.com/$1 [R=301,L]
If you've got two servers you don't really have much choice but to use a redirect (ideally a 301 Permanent redirect) to move users from domain.com/forum to forum.domain.com.
The only other way to do it would be to put a reverse proxy in front of those two servers, which reads the URL and internally directs the query to the right server, but that's then an extra piece of hardware.