开发者

.htaccess redirect when domain name is unknown

开发者 https://www.devze.com 2023-02-19 18:14 出处:网络
I have a site that I am not sure what the domain name will eventually be when it\'s live, but as I am working on it I access it through a local server. One of the directories on the site needs to be r

I have a site that I am not sure what the domain name will eventually be when it's live, but as I am working on it I access it through a local server. One of the directories on the site needs to be redirected. To save time when the site goes live (and also just to learn how) I am trying to write a .htaccess statement that will redirect the directory regardless of what the domain name is. Currently I access the site through:

http://phuk9220/

I want this directory:

/audio/help-and-faqs/

to redirect to:

/audio/help-and-faqs/welcome/

Now, I can easily do this with:

RedirectMatch 301 ^/audio/help-and-faqs/$ http://phuk9220/audio/help-and-faqs/welcome/

However, it means changing the http://phuk9220/ to whatever domain will it will eventually be on. Is there anyway of changing the domain dynamically depending on where it actually is ?

Thanks in advance and开发者_运维知识库 if you have any questions, please ask.

Alex


Simply omitting the domain name entirely should do the redirect on the same domain that was requested.

RedirectMatch 301 ^/audio/help-and-faqs/$ /audio/help-and-faqs/welcome/
0

精彩评论

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