使用htaccess的子域目录重定向

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

我想重定向这样的事情

sub-domain.domain/directory到domain/directory~~V

sub-domain.domain/directory to domain/directory

我试过重定向301 / domain/directory [htaccess的放置在子域文件]它工作正常子域名,但不会为子域内的目录工作。

I tried Redirect 301 / domain/directory [htaccess file placed in sub-domain] it works fine for the sub-domain but won't work for the directory within the sub-domain.

有人能帮我什么应该是.htaccess文件的内容?

Can somebody help me with what should be the content of .htaccess file ?

感谢。

推荐答案

如果您只是想从xxx.domain/yyy重新定向所有的请求www.domain/yyy~~V你可以使用:

If you simply want to re-direct all requests from xxx.domain/yyy to www.domain/yyy you can use:

RewriteCond %{HTTP_HOST} !^www\.domain\ [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*) www.domain/com/$1 [L,R]

注意:您需要确保重写引擎是第一次,等

NB: You'll need to ensure that the rewrite engine is on first, etc.

更新..

如果你只是想要一个301,在最后一行更改[L,R] [L,R = 301]

If you just want a 301, change the [L,R] on the last line to [L,R=301]

更多推荐

使用htaccess的子域目录重定向

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

发布评论

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

>www.elefans.com

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