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]
Related
First I need to redirect these pages to another page in a different domain
Redirect 301 /example1 http://newdomain.com/test1
Redirect 301 /example2 http://newdomain.com/random1
Note the pages are not the same in the new domain (e.g., /example1 to /test1)
After that, I need redirect the rest of the pages to newdomain.com
E.g., Redirect 301 (everything else) to http://newdomain.com
Try below rule, using mod rewrite I am assuming you have mod rewrite enabled.
RewriteEngine On
RewriteRule ^example1$ http://newdomain.com/test1 [R=301,L]
RewriteRule ^example2$ http://newdomain.com/random1 [R=301,L]
RewriteCond %{REQUEST_URI} !^(example1|example2)
RewriteRule ^ http://newdomain.com [R=301,L]
If you want to use mod-alias , you can use these redirects :
RedirectMatch 301 ^/example1/?$ http://example.com/test1
RedirectMatch 301 ^/example2/?$ http://example.com/random1
#redirect everything else to the homepage of example.com
RedirectMatch ^.+$ http://example.com/
Clear your browser cache before testing these redirects.
Try this in your .htaccess
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]
I have a old domain lets call it
example.com
I want to do a 301 redirect of all its page and its homepage to
newsite.com
So for example
example.com/category/page.html
Should 301 redirect to
newsite.com/category/page.html
And also
example.com should redirect to newsite.com
Be it with www or without www
I tried the following
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://www.newsite.tv/$1 [L,R=301,NC]
My folder structure is
index.html
.htaccess
When I go in the site, be it with wildcard or not, it only load the index.html and the .htaccess redirect is not working.
I did enable modrewrite
Can anyone guide me to set up the right .htaccess for this case.
Thanks!
You can also use RedirectMatch directive .
Try this in Olddomain/.htaccess :
RedirectMatch ^/(.*)$ http://newsite.com/$1
I'd like to make a 301 redirect, but only on one specific link:
http://www.example.com/example.html
in htaccess, Apache
You can try this
RewriteEngine on
RewriteCond %{HTTPS} ^on
RewriteRule ^example\.html$ http://www.example.com/example.html [R=301,L]
I am having an issue with my 301 redirects.
I just upgraded my site from an html based site to a joomla site. SO I am trying to redirect the 50 or so pages to the new joomla based navigation.
SO what is working:
rewrite rule to remove index.php, and the www., and 301 redirects
What isn't working:
301 redirect with a www in front of it.
www.sample.com/page.html
It sends them to the home page instead of the page, it takes them to the home page.
Here is my www rewrite rule.
## Redirects to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} www.sample.com
RewriteRule (.*) http://sample.com/$1 [R=301,L]
Here is my 301 rule
Redirect 301 /page.html /page
Thanks for the help.
If you are trying to remove the www then you might want to change the matching up some. Try your rule like this.
## Redirects to www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sample\.com$ [NC]
RewriteRule (.*) http://sample.com/$1 [R=301,L]
RewriteRule ^page.html$ /page [R=301,L]
RewriteRule ^page2.html$ /page2 [R=301,L]
A new website has just gone live and there is a htaccess file which has 301 redirects in order to direct people from the old pages on the old domain to the new pages on the new domain.
However, because there is a ? and = symbol in the links it's not working.
I understand I'll need to take advantage of the query string, but I can't work out how to get these three examples working.
Redirect 301 /index.cfm?task=what_we_do http://domain.com/services/
Redirect 301 /pagecontent/_newsitem.cfm?newsid=63 http://domain.com/name-of-article/
Redirect 301 /pagecontent/_people.cfm?peopleid=3 http://domain.com/about-us/meet-the-team/john-smith/
Can anyone help?
You can't use a query string in the redirect. you have to use mod_rewrite.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^task=what_we_do$
RewriteRule ^index.cfm http://domain.com/services/? [R=301,L]
RewriteCond %{QUERY_STRING} ^_newsid=63$
RewriteRule ^pagecontent/_newsitem.cfm http://domain.com/name-of-article/? [R=301,L]
RewriteCond %{QUERY_STRING} ^_peopleid=3$
RewriteRule ^pagecontent/_people.cfm http://domain.com/about-us/meet-the-team/john-smith/? [R=301,L]