Hey Stack Overflowers.
I created a blog using php, mysql and php router concept.
All request going to index.php there I am dynamically get data from database then showing to them.
My problem is all request are going to index.php but i need to redirect except sitemap , robots & /admin folder
My folder structure:
-example.com
-admin
-assets
-function
-views
.htaccess
index.php
config.php
sitemap.php
robots.txt
My htaccess code:
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
#RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
</IfModule>
Just below RewriteEngine on
line, you can add this rule:
RewriteCond %{THE_REQUEST} \s/+(?:sitemap\.php|robots\.txt|admin/) [NC]
RewriteRule ^ - [L]
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.