I want to redirect all the .html file like this:
www.sitename.com/art/5.html
to the following (equivalent) php page:
www.sitename.com?art=5
but ONLY if the .html file doesn't exist, otherwise it should not redirect. What should I write in my .htaccess file?
Use :
# Test if the file exist
RewriteCond %{REQUEST_FILENAME} !-f
# And redirect if not
RewriteRule ^(.+)/(.+)\.html$ /?$1=$2 [QSA,L,R=301]
试试这个untested
应该工作
RewriteRule ^(.*)/(.*)\.html$ /?$1=$2 [L,R=301]
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.