I am sure this is pretty simple, but i just cant find the right code for it.
I need to redirect everything, old domain, with and without www all sub pages.any random link that may be out there to www.newdomain.com
Here is mine at the moment, and it redirects well, exceprt for one thing
www.old-doamin.com/old-page - redirects to www.newdomain.com/old-page
When it should be going to the home page of the new page.
thank you for the help.
RewriteCond %{HTTP_HOST} ^old-domain.com/$
RewriteRule (.*) http://www.old-domain.com/$1 [R=301,L]
RedirectMatch 301 ^/(.*)http://www.newdomain.com/$1
Why dont you do it through DNS? CNAME redirect would probably be best so the old-domain.com traffic is redirected?
If you want to go with htaccess, this should do the trick:
RewriteEngine on
RewriteCond %{HTTP_HOST} old\.com$
RewriteRule .* http://www.new.com/ [L,R=301]
Make www optional, this should work for you:
RewriteCond %{HTTP_HOST} old-domain\.com$ [NC]
RewriteRule ^ http://www.newdomain.com/ [R=301,L]
Don't forget to take out both of your existing rules.
Related
My goal is to 301 all variants of my domain name to forever be https://*.com via htaccess. Also, is this is the best way to go about accomplishing it?
E.g., http://, http://www. and https://www. >> https://
I would like for all of its files and/or subdirectories to be https:// as well.
You can simply just do this.
RewriteEngine On
RewriteCond %{HTTPS} !^on [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
Make sure you clear your browser cache before trying these new rules. Let me know how this works out.
htaccess snippets to redirect all pages to one page but none of them are working for me.
I need olddomain.com , olddomain.com/pricing , olddomain.com/about , etc all to point to newdomain.com.
So olddomain.com/pricing shout not go to new domain.com/pricing.
It should just go to newdomain.com.
How can I do this?
Nothing simpler then that.
If it are different webservers, you can write this on the old ones:
RewriteEngine On
RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L]
^(.*)$ means everything
http://www.newdomain.com is the target
If it is still the same webserver
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)newdomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com [L,R=301]
It is pretty the same, but you have the condition, that the host is not newdomain.com.
RedirectMatch 301 (?i)/* http://www.yourdomain.com/WHATEVER
or
RedirectMatch 301 (?i)/OLD/* http://www.yourdomain.com/WHATEVER
This will go in the htaccess in your old domain root. If they are not on the same server you don't need the RewriteCond line.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain.com$ [NC]
RewriteRule ^(.*) http://newdomain.com/ [R=301,L]
Try this and let me know how it works for you.
I have a .htaccess file set up to redirect any of the following:
http://mydomain.com
http://www.mydomain.com
http://mydomain.co.uk
to:
http://www.mydomain.co.uk
The code in the .htaccess is shown below (I realise the first line is nothing to with the redirect. I've left it in to show the code exactly as it is).
suPHP_ConfigPath /data01/xxxxx/public_html/php.ini
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
This code works perfectly, but now the client has thrown another variable into the mix. They also want to redirect the following:
https://
to
http://
I'm not sure how to implement this. I've searched for similar examples, but can't find an example that combines all the redirects that I need.
Hope this all makes sense! It's the first time I've posted a question, so I hope I've done it correctly.
Any help much appreciated :)
You can have rule this way:
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} !^www\.mydomain\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=301,L]
I am updating the Iirf.ini file to redirect sub.columbia.edu to giving.columbia.edu/video.
sub.columbia.edu is already redirecting to giving.columbia.edu.
How can I go one step further to redirect it to giving.columbia.edu/video.
Important Note: I would like the URL to show as sub.columbia.edu in the browser and not as giving.columbia.edu/video
#Redirect subdomain to specific URL
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^/$ /video
The above doesn't work. Any ideas how I should modify this?
Thank you!
You can try this and see how it works for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.columbia\.edu
RewriteRule ^(.*) http://giving.columbia.edu/video [L,R=301]
Or you can do a redirect, this should work also.
Redirect 301 / http://giving.columbia.edu/video
Read a ton on creating the proper redirects, but still having an issue.
Moving a site from one domain unto another. The directory structure has changed as well. The subpages are working great, but the home page isn't. Here the code that I'm using:
RewriteEngine on
//301 Redirect Old File
RewriteRule oldsite.net newsite.com [R=301,L]
RewriteRule ^p_gallery.* http://www.newsite.com/gallery [R=301,L]
RewriteRule ^p_purchase.* http://www.shop.newsite.com [R=301,L]
Thanks!
Make sure you have enabled mod_rewrite.
Because your first rule is wrong:
RewriteRule oldsite.net newsite.com [R=301,L]
You can only match REQUEST_URI in the RewriteRule.
It should be like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.net$ [NC]
RewriteRule ^ http://newsite.com%{REQUEST_URI} [R=301,L]