简体   繁体   中英

.htaccess in subfolder work partially

The website's structure is the next:

www.mydomain.com -> Here is installed wordpress.
www.mydomain.com/subfolder1 -> Here is installed a custom php Application. www.mydomain.com/subfolder1/subfolder2 -> Here is installed Control panel of 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;

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

Any advices?

.htaccess in subfolder1

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

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.

Or keep that and change the RewriteBase as the first .htaccess

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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