I'm trying to redirect to url to a single new url
http://www.domain.com/ --> http://www.domain.com/v3/
http://www.domain.com/v2 --> http://www.domain.com/v3/
Here's what I did
RewriteEngine on
RewriteRule ^v2/(.*) http://www.domain.com/v3/ [R=301,L]
RewriteRule ^(.*) http://www.domain.com/v3/ [R=301,L]
Try this:
Redirect 301 /v2 http://domain.com/v3
Redirect 301 / http://domain.com/v3/
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 have url
/en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage%E2%80%8B
and I try
Redirect 301 /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\%E2\%80\%8B /en
or
RewriteCond %{THE_REQUEST} ^\w+ /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage%E2%80%8B
RewriteRule ^ /en [R=301,L]
or
Redirect 301 /en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\%E2\%80\%8B /en
But any version don't work. How I can redirect from this url?
You can use this rule as your first rule in site root .htaccess:
RewriteEngine On
RewriteRule ^en/parlour-profile/massage-parlour-anna-berry-massage-louise-sensual-massage\xE2\x80\x8B/?$ /en? [L,NC,R=301]
\xMN is used in RewriteRule pattern to match %MN in URL.
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 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]
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/