htaccess的子目录

法哈德

我在生产中的网站带有自己的.htaccess文件:

DirectoryIndex index.php

RewriteEngine On


RewriteRule ^about$ about.php [NC]
RewriteRule ^contact$ contact.php [NC]
RewriteRule ^portfolio$ portfolio.php [NC]
RewriteRule ^home$ index.php [NC]
RewriteRule ^companies$ companies.php [NC]

我在子目录my_site.com/demo_site中创建了新站点的demo_version,我想在my_site.com中为子目录的htaccess重写规则编写规则:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php

我如何拆分此规则?

阿努巴瓦

将.htaccess的第一部分保留在根.htaccess中,并将其保留在以下位置/demo_site/.htaccess

DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine on
RewriteBase /demo_site/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章