[英].htaccess in subfolder work partially
下一个是网站的结构:
www.mydomain.com->这是安装的wordpress。
www.mydomain.com/subfolder1->这里安装了一个自定义php应用程序。 www.mydomain.com/subfolder1/subfolder2->此处安装了php Application的控制面板。
我在子文件夹1中有一个.htaccess,在子文件夹2中有另一个。子文件夹1中的导航很棒,但是子文件夹2中的导航是错误的;
我可以看到www.mydomain.com/subfolder1/subfolder2/index.php,但是如果我想在菜单中浏览,例如www.mydomain.com/subfolder1/subfolder2/测试网址更改,但我总是看到index.php
有什么建议吗?
.htaccess在子文件夹1中
Option -Indexes
ErroDocument 404/404.php
RewriteEngine On
RewriteBase /subfolder1/
#Remove extra trailing slashes
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule . %1/%2 [R=301,L]
#Add missing trailing slash
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteRule /(uploads/.*) $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
<ifModule mod_deflate.c>
<filesmatch "\.(js|css|html|jpg|png|gif|eot|woff|ttf|svg)$">
SetOutputFilter DEFLATE
</filesmatch>
</ifModule>
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|cache|tpl)$">
Order Allow,Deny
Deny from all
</FilesMatch>
subfolder2中的.htaccess与subfolder1类似,但我更改了RewriteBase
Option -Indexes
ErroDocument 404/404.php
RewriteEngine On
RewriteBase /subfolder1/subfolder2/
#Remove extra trailing slashes
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule . %1/%2 [R=301,L]
#Add missing trailing slash
RewriteCond %{REQUEST_URI} /+[^\.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]
RewriteRule /(uploads/.*) $1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/subfolder2(.+)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ subfolder2/index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
<ifModule mod_deflate.c>
<filesmatch "\.(js|css|html|jpg|png|gif|eot|woff|ttf|svg)$">
SetOutputFilter DEFLATE
</filesmatch>
</ifModule>
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|cache|tpl)$">
Order Allow,Deny
Deny from all
</FilesMatch>
您已经更改了RewriteBase,因此无需在RewriteCondition和RewriteRule中放置“ subfolder2”。
或者保留该名称,并将RewriteBase更改为第一个.htaccess
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.