问题
I have this code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]
RewriteRule ^/newfolder/(.+) /index.html/$1 [L,NC]
I want all files from newfolder (located in public_html) to be rewrite to index.html which is in public_html, ofcourse. Any help please...
回答1:
Remove leading slash from your regex to match URI:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]
RewriteRule ^newfolder(/|$) /index.html [L,NC]
.htaccess
is per directory directive and Apache strips the current directory path (thus leading slash) fromRewriteRule
URI pattern.
来源:https://stackoverflow.com/questions/21676105/rewrite-all-files-from-newfolder-to-index-html