I´ve got a press portal for my second tld and I wnat to redirect that to my .com domain, but this one is not working:
RedirectMatch 301 https://www.demostore.nl/persbericht/.* https://www.demostore.com/press-portal
What am I doing wrong?
RedirectMatch only matches request URL without scheme, port and domain name.
You can use this rule instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?demostore\.nl$ [NC]
RewriteRule ^persbericht/(.*)$ https://www.demostore.com/press-portal/$1 [L,NC,NE,R=301]
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 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]
I need to redirect WWW and non-WWW domain to different domain ending. Both domains are on the same cPanel.
How do I do that via .htaccess? This is my current .htaccess:
RewriteCond %{HTTP_HOST} ^abc\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.abc\.com$
RewriteRule ^/?$ "http\:\/\/www\.abc\.co\.nz\/" [R=301,L]
It depends what you want to redirect. But for example if you wanted to redirect a page called abc to a website: def.com you would use:
redirect 301 /abc http://def.com
Not sure if this is exactly what you want but I hope it helps.
In that case then all you need to do is put this code in your .htaccess of domain.com:
redirect 301 / http://domain.co.nz
This will redirect any part of domain.com to domain.co.nz