我希望写在.htaccess规则重定向
I want write a rule in .htaccess for redirecting
www.dir.domain dir.domain www.domain/dir这些应该重定向到
domain/dir
在此先感谢...
Thanks in advance...
推荐答案这里的技巧是使用的.htaccess 文件在您DOCROOT
The trick here is to use an .htaccess file in your DOCROOT
RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www\.)?dir\.domain\$ RewriteRule ^.* domain/dir/$0 [R=301,L] RewriteCond %{HTTP_HOST} ^www\.domain\$ RewriteRule ^dir/.* domain/$0 [R=301,L]请注意,这是在做301重定向 - 这是服务器告诉浏览器,这是一个永久重定向和浏览器缓存此重定向
Note that this is doing a 301 redirect -- that is the server tells the browser that this is a permanent redirect and the browser caches this redirect.
您也可以做一个内部重定向,其中该映射默默的在服务器端通过调整标志完成。
You can also do an internal redirect where this mapping is done silently at the server end by tweaking flags.
这假定您的共享服务使用Apache的,如果使用IIS,那么你需要做的web.config中类似的事情
This assumes that your shared service is using Apache, if its using IIS, then you need to do something similar with the web.config
更多推荐
子域名重定向
发布评论