简体   繁体   English

子文件夹中的.htaccess部分工作

[英].htaccess in subfolder work partially

The website's structure is the next: 下一个是网站的结构:

www.mydomain.com -> Here is installed wordpress. www.mydomain.com->这是安装的wordpress。
www.mydomain.com/subfolder1 -> Here is installed a custom php Application. www.mydomain.com/subfolder1->这里安装了一个自定义php应用程序。 www.mydomain.com/subfolder1/subfolder2 -> Here is installed Control panel of php Application. www.mydomain.com/subfolder1/subfolder2->此处安装了php Application的控制面板。

I have an .htaccess in subfolder1 and another in subfolder2, the navigation in subfolder1 is great, but the navigation in the subfolder2 is wrong; 我在子文件夹1中有一个.htaccess,在子文件夹2中有另一个。子文件夹1中的导航很棒,但是子文件夹2中的导航是错误的;

I can see the www.mydomain.com/subfolder1/subfolder2/index.php but if i want navigate in the menu ie www.mydomain.com/subfolder1/subfolder2/test the url change, but i see always the index.php 我可以看到www.mydomain.com/subfolder1/subfolder2/index.php,但是如果我想在菜单中浏览,例如www.mydomain.com/subfolder1/subfolder2/测试网址更改,但我总是看到i​​ndex.php

Any advices? 有什么建议吗?

.htaccess in subfolder1 .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>

.htaccess in subfolder2 is similar subfolder1 but i have changed the RewriteBase 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> 

You have changed the RewriteBase, so you don't need to put "subfolder2" in RewriteCondition and RewriteRule. 您已经更改了RewriteBase,因此无需在RewriteCondition和RewriteRule中放置“ subfolder2”。

Or keep that and change the RewriteBase as the first .htaccess 或者保留该名称,并将RewriteBase更改为第一个.htaccess

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM