Simple .htaccess subdomain rewrite

做~自己de王妃 提交于 2019-12-19 20:34:10

问题


I know there is a lot of questions on here about this... but right now I feel like a deer stunned by oncoming headlights... I just don't know where to start and which option to choose.

My requirements are simple.

User goes to http://application.domain.com or http://www.application.domain.com and the real location of these files is http://www.domain.com/application

Obviously this needs to be done using wildcards so that any domain (even if it doesn't exist) triggers the rewrite.

I hope this makes sense to someone

EDIT: I should also mention I have added the wildcard A record to my DNS entries in Cpanel *.domain.com

Thanks

Tim


回答1:


I posted this question onto serverfault.com and icyrock solved it. Incase anyone else is wondering the answer given is here:

https://serverfault.com/questions/203780/troubleshooting-a-htaccess-wildcard-subdomain-rewrite/203804#203804

Tim




回答2:


Simplest way in .htaccess would be to put the following in an htaccess file as high up in the hierarchy as possible.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.application\.* [OR]
RewriteCond %{HTTP_HOST} ^application\.* [NC]
RewriteRule .* http://www.domain.com/application [L]


来源:https://stackoverflow.com/questions/4193651/simple-htaccess-subdomain-rewrite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!