开发者

Is this possible with .htaccess?

开发者 https://www.devze.com 2023-03-10 19:28 出处:网络
I\'ve purchased a new domain (let\'s call this domain1.com) and I\'d like to use my existing hosting package (let\'s call this domain0.com) to host the website (powered by Wordpress) - I can re-direc开

I've purchased a new domain (let's call this domain1.com) and I'd like to use my existing hosting package (let's call this domain0.com) to host the website (powered by Wordpress) - I can re-direc开发者_Go百科t domain1.com to domain0.com/domain1 or domain1.domain0.com.

Is it possible, using .htaccess to do this? Bear in mind that this will be Wordpress-based and so there'll be some extra .htaccess action to get 'pretty permalinks' - will this complicate things even further?

To clarify:

  • user enters www.domain1.com
  • gets sent to www.domain0.com/domain1/
  • htaccess magic makes it look like they are on www.domain1.com


What you're asking is not possible using mod_rewrite only.

Please understand that Apache doesn't do internal redirect if HOSTNAME is changing in the target of a RewriteRule. In that case it has to be an external redirect using R flag. And if there is an external redirect then domain name of URL in the browser will change to http://www.domain0.com.

One possible workaround that you can use is to set the DOCUMENT_ROOT for www.domain1.com to domain0_DOCUMENTROOT/domain1.


if i understood your problem then yes you can redirect users like this in .htaccess:

RewriteRule ^([^/]*)$ http://www.domain0.com/domain1.php?req=$1 [QSA,L]

also you can redirect user to a special page using .htaccess and then in that special page redirect user wherever you want using php or javascript or anything else.


ok. now i get it .i'm not sure but i think that you cannot redirect a user from a domain to another without address changing! but you can redirect from www.domain1.com to www.domain0.com/domain1 and with .htaccess you can hide "/domain1" at the end of your address. does it helps?

0

精彩评论

暂无评论...
验证码 换一张
取 消