简体   繁体   中英

htaccess rewrite all pages to same rule

I have added a rewrite rule in htaccess file and it is working fine the only problem is if I open any URL from after 2016 directory it opens the same target file.

RewriteRule ^elections/assembly/2016/(.*)$ elections/assembly/2016/index.php?state=$1

For example :-

http://www.example.com/elections/assembly/2016/dir1/dir2/index.php

the above URL follow the same pattern. please help me to resolve this.

You have to exclude your real files and dirs from the rule :

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^elections/assembly/2016/(.*)$ elections/assembly/2016/index.php?state=$1

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