I am trying to move my website from a domain and server where I am just a user to a domain that I control.
I want to redirect every request at http://www.olddomain.com/~username/ to http://www.newdomain.com/ - and I only have access to ~username on the server.
Everything I try ends up at http://www.newdomain.com/~username/
1)
Redirect 301 / http://www.newdomain.com/
2)
Redirect 301 /~username/ http://www.newdomain.com/
3)
RewriteEngine on
RewriteBase /
RewriteRule ^~username/(.*)$ http://www.newdomain.com/$1 [R=301,NC,L]
4)
RewriteEngine on
RewriteBase /~username/
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,NC,L]
I would probably prefer to redirect everything to just http://www.newdomain.com/index.html , but for the sake of completeness please also show how to redirect to a matching URL on the new server.
Apache mod_rewrite docs:
Per @Capsule's comment, I just needed to clear the cache in my browser. Refreshing the page / revisiting the old domain is not sufficient.
Firefox -> History -> Clear Recent History... -> Last Hour
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.