使用.htaccess重定向子域而不更改URL

时间:2017-12-02 22:23:36

标签: apache .htaccess redirect mod-rewrite

想知道你是否可以帮我解决一些.htaccess。

我想让sub.example.com显示来自example.com/sub的数据而不更改网址: 即。 sub.example.com将保留sub.example.com,尽管它是从example.com/sub

中读取的

我在.htaccess中有以下数据:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.example.com
RewriteRule ^(.*)$  http://example.com/sub/$1 [L,NC,QSA]

我尝试将[L,NC,QSA]更改为[P]但我收到错误403 - 禁止访问。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:-1)

RewriteCond %{HTTP_HOST} ^sub.example.com [NC]
RewriteRule ^(.*)$ http://example.com/sub/$1 [L,R=301]
相关问题