I have an .htacess on the root of my domain to redirect all traffic to index.php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#redirect http to https, remove www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#remove index.php from link
RewriteRule ^index.php$ - [L]
#redirect to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
#remove direct access to all *.php except index.php
<Files *.php>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Files>
<Files index.php>
Order Allow,Deny
Allow from all
</Files>
Everything works as expected, traffic is redirect, when files exists show file.
now i have an admin folder /admin/ with and index.php and api.php i can open the /admin/ and /admin/index.php but the /admin/api.php redirects to /index.php
i tried to put an .htaccess inside the /admin/ like this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine Off
RewriteEngine On
#redirect http to https, remove www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
but getting the same results. /admin/ opens, but /admin/api.php redirects to index
found the problem/solution.
needed to add to the .htaccess inside the /admin/
<Files *>
Order Allow,Deny
Allow from all
</Files>
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.