简体   繁体   English

htaccess将子文件夹重定向到子域

[英]htaccess redirect subfolder to subdomain

I'm running Apache mod_rewrite on a Linux server and I need to redirect a subfolder to a sub-domain and remove the subfolder from the url. 我在Linux服务器上运行Apache mod_rewrite,需要将子文件夹重定向到子域,然后从URL中删除子文件夹。 For example: 例如:

http://www.mydomain.com/forum/forum_posts.asp?TID=11816&PID=252908&title=pouch-information-day-the-next-one#252908 http://www.mydomain.com/forum/forum_posts.asp?TID=11816&PID=252908&title=pouch-information-day-the-next-one#252908

needs to redirect to 需要重定向到

http://subdomain.mydomain.com/forum_posts.asp?TID=11816&PID=252908&title=pouch-information-day-the-next-one#252908 http://subdomain.mydomain.com/forum_posts.asp?TID=11816&PID=252908&title=pouch-information-day-the-next-one#252908

Please can anybody help? 有人可以帮忙吗?

The Apache URL Rewriting Guide is a great reference. Apache URL重写指南是一个很好的参考。 This is how I would do it: 这就是我要做的:

RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.mydomain.com/forum/
RewriteRule ^/forum/(.*) http://subdomain.mydomain.com/$1 [L,R]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM