我在生产中使用自己的.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
我如何拆分此规则?
答案 0 :(得分:1)
将.htaccess的第一部分显示在root .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]