I've got a site http://abcd.com that I want to redirect to http://efgh.com . This works.
But unfortunately I have to use an .htaccess provided by the domain hoster as the first URL has no actual web space behind it.
The problem is both .htaccess and meta-refresh within the second page don't actually update the URL as far as the browser is concerned (ie the location-bar still shows abcd.com even though we're on efgh.com). That is an issue because cookies from the page are therefore treated as third-party cookies.
How do I change the URL the browser thinks it's on to solve the cookie issue?
EDIT: Perhaps I wasn't clear enough: The redirect itself works . The content is from efgh.com . But the location bar in the browser shows abcd.com which is important because it turns cookies from efgh.com into third-party cookies.
EDIT2: Aargh, after bashing my head against the wall for ages I only now realized the domain hoster boxed me into a hidden frameset. I can't believe I was this stupid and didn't realize it sooner.
Make sure to use R' flag in your
RewriteRule` for external redirection (change the URL).
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?abcd\.com$ [NC]
RewriteRule ^ http://efgh.com%{REQUEST_URI} [R=301,L]
Since you're using R=301
here, make sure to test in a different browser.
One way to achieve this would be to send a 301 redirect for the old domain in your .htaccess file.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !newdomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]
Notice the R=301
on the last line - this will tell the browser that the move is permanent - the browser will then move on to another domain.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.