在域之前配置.htaccess子路径

时间:2017-10-02 13:47:54

标签: .htaccess redirect dns

我想要完成一些事情: 我将example.com作为域和example.com/subpath,每当你登陆example.com/subpath并点击节点时,它都是example.com/subpath/node。 我需要在.htaccess中编写一条规则,以便当用户登陆子路径时,url将变为: subpath.example.com/node

有什么建议吗? 我在考虑使用变量,但对此并不十分自信。

1 个答案:

答案 0 :(得分:0)

您需要使用重写规则。试试这个

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

DirectoryIndex                                      page/index.html //first page

RewriteRule ^node$                              

subpath/node.php [QSA,L]