I'm really stuck with now so would appreciate any help.
I am trying to redirect a site to another domain but with some exceptions. Here is the code I have now in my .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/sitemap/
RewriteCond %{REQUEST_URI} !/contact-us/
RewriteRule ^.*$ http://www.newsite.com/folder/$0 [R=301,L]
Redirect 301 /sitemap/ http://www.newsite.com/sitemap/
Redirect 301 /contact-us/ http://www.newsite.com/contact-us/
Any ideas why this may not be working?
The home page and the sitemap and contact us pages redirect fine but all other pages are not redirected.
Thanks in advance.
Move the Redirect lines higher
RewriteEngine On
Redirect 301 /sitemap/ http://www.newsite.com/sitemap/
Redirect 301 /contact-us/ http://www.newsite.com/contact-us/
RewriteBase /
RewriteCond %{REQUEST_URI} !/sitemap/
RewriteCond %{REQUEST_URI} !/contact-us/
RewriteRule ^.*$ http://www.newsite.com/folder/$0 [R=301,L]
I tried this on my apache server and it worked
http://www.oldsite.com/sitemap/ => http://www.newsite.com/sitemap/
http://www.oldsite.com/contact-us/ => http://www.newsite.com/contact-us/
http://www.oldsite.com/test => http://www.newsite.com/folder/test
Related
I can redirect all traffic to new blog subdirectory like:
Redirect 301 / https://new-website.com/blog/
However, I want this redirect to happen ONLY if it comes from old website subdomain referral:
https://blog.old-website.com
Any idea?
You can use mod-rewrite
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^https://blog\.oldsite\.com
RewriteRule ^.*$ http://newsite.com/blog%{REQUEST_URI} [L,R]
I need the sloution for home page 301 redirection.
If I enter http://www.starmed.dk/index.php in the browse bar, then it will be redirected to http://www.starmed.dk without index.php
Any idea how to do this with an HTACCESS 301 redirect?
Thanks in advance.
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^starmed.dk[nc]
RewriteRule ^(.*)$ http://www.starmed.dk/$1 [r=301,nc]
//301 Redirect Old File
Redirect 301 www.starmed.dk/index.php www.starmed.dk
Edit:
Perhaps your configuration is different. perhaps this:
RewriteRule ^www.starmed.dk/index.php$ www.starmed.dk/ [R=301]
Try the following :
DirectoryIndexRedirect Off
RewriteEngine on
RewriteRule ^index\.php$ / [L,R]
Recently moved a site over from a subdomain into a subdirectory of the root domain.
http://blog.domain.com to http://domain.com/blog.
I dropped this into my .htaccess at http://blog.domain.com, so users going to articles with old URLs will be redirected accordingly.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_REFERER} ^http://blog.\domain\.com
RewriteRule .* http://domain.com/blog [R=301,L]
I am unable to figure out how to redirect http://blog.domain.com to http://domain.com/blog. The snippet above does not do that. Any insights would be greatly appreciated!
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.domain\.com$
RewriteRule ^(.*)$ http://domain.com/blog/$1 [L,R=301]
I'm moving my site from old-domain.com to new-domain.com with exactly the same pages, e.g., if old-domain.com has a page1.html (i.e., old-domain.com/page1.html) then the new domain has the same page, i.e., new-domain.com/page1.html
I tried this in the .htaccess file:
RewriteEngine on
RewriteRule (.*) http://new-domain.com/$1 [R=301,L]
But only while old-domain.com will redirect to new-domain.com, old-domain.com/page1.html will not redirect to new-domain.com/page1.html
Thanks!
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
See here for more solutions: http://enarion.net/web/htaccess/migrate-domains/
Try this in your htaccess
Redirect 301 / http://www.new.com/
This will redirect (and map) all your pages from http://old.com/page1 to http://new.com/page1
Try this:
RedirectPermanent / http://www.new-domain.com/
I am finding some problems in the htaccess of CMS with a 301 redirect.
When trying to solve canonical urls (redirecting site to www.site) I got the problem that I cannot log in in the back end (www.site/admin).
The htaccess condition is:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.site\.co.uk$
RewriteRule (.*) http://www.site.co.uk$1 [R=301,L]
I guess I need to include a expression that allows the URI /admin not to be redirected, but how?
Like this, for example:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !=www.example.co.uk
RewriteCond %{REQUEST_URI} !^/admin
RewriteRule .* http://www.example.co.uk%{REQUEST_URI} [R=301,L]