开发者

RewriteCond to change displayed host, but not server

Typing out the title to this leads me to believe this might not be possible due to security concerns, but I will ask anyway. I have shortcode support running on my server, lets call it xx.yy

I want it so when a user sends a request to xx.yy, it just changes the displayed host to another valid domain running on the same box.

I have this so far (lets the server know to accept requests from xx.yy):

RewriteCond %{HTTP_HOST}   ^.*xx.yy [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]

RewriteCond %{HTTP_开发者_开发知识库HOST}   ^.*mysite.com [NC]
RewriteRule ^/(.*)$ http://127.0.0.1:<PORT_OMITTED>%{REQUEST_URI} [P,QSA,L]

It works, and it directs the traffic into my app, but the url says http://xx.yy when I would rather it say http://mysite.com

I know i could redirect to http://mysite.com instead of 127.0.0.1, but I have 4 parallel boxes of mysite.com and going back out to DNS to maybe go to another box seems like a waste when I am already here. Also, I am not sure how POST requests would work like that.

What can I do?


If mysite.com is on the same box, and DNS is pointing there, just put R=301 in [P,QSA,L]

Example

RewriteEngine on
RewriteCond %{HTTP_HOST} ^OldDomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.OldDomain.com$
RewriteRule ^(.*)$ http://www.NewDomain.com/$1 [R=301,L]

From http://www.liewcf.com/redirect-webpages-to-another-domain-538/

Other than that, though there's no way for good reasons to do what you are asking. Imagine if someone could link to legitwebsite.com, but have it get sent to evilempire.com.

It'd be chaos, that's what.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜