Reputation: 15
After searching all the other solutions I haven't found a working example on stackoverflow.
My main website redirects accordingly, but when I want to do they same thing to a subfolder/admin folder it inherits the parents search patterns and does not use the landing page in the admin folder.
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteRule ^/?(.*)\ (.*)$ /$1-$2 [R=301,L]
To allow access to the admin sub folder I have another htaccess file that has:
RewriteEngine Off
To clarify I do attempt to turn this folders htaccess on so I can redirect the queries, only leaving it off has successfully accessed the admin sub folder, but any trailing query is back to the main site.
I've tried the following on both htaccess files
RewriteRule ^admin/$ admin/index.php [QSA,L]
Turning it off and then back on in the sub directory htaccess.
RewriteEngine Off
RewriteEngine On
Please advise thanks.
Upvotes: 1
Views: 327
Reputation: 785146
Have it this way:
DocumentRoot/.htaccess
:
RewriteEngine On
RewriteBase /
# strip spaces
RewriteRule ^/?(.*)\ (.*)$ /$1-$2 [R=301,L]
## add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,NE,L]
/admin/.htaccess
:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /admin/
RewriteRule ^index\.php$ - [L,NC]
# forward everything to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Upvotes: 1