子域名重定向

编程入门 行业动态 更新时间:2024-10-26 14:36:39
本文介绍了子域名重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望写在.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

更多推荐

子域名重定向

本文发布于:2023-11-01 19:49:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550246.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   域名

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!