我一直在使用以下代码在嵌套目录中重写请求变量。
RewriteEngine on
RewriteRule ^demos/folder1/page\.php$ - [L]
RewriteRule ^demos/folder1/([^/]+)/([^/]+)$ demos/folder1/page.php?slug=$1 [NC]
RewriteRule ^demos/folder1/([^/]+)$ demos/folder1/page.php?slug=$1 [NC] /* ruins everything, with other links *
它位于根目录中的.htaccess文件中,而不是/ folder1 /。知道为什么它会导致服务器上的其他.php文件无法显示?我只需要将/demo/folder1/page.php请求重写为/ demo / folder1 / REQUEST。我错过了什么?
提前谢谢!
答案 0 :(得分:1)
Try this code:
RewriteEngine on
RewriteRule ^demos/folder1/page\.php$ - [L,NC]
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^demos/folder1/([^/]+)/?$ demos/folder1/page.php?slug=$1 [QSA,NC,L]