重写所有文件从newfolder到的index.html

问题描述:

我有这个code:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (mozilla|navigator|chrome) [NC]
RewriteRule ^/newfolder/(.+) /index.html/$1 [L,NC]

我想从newfolder(位于的public_html)中的所有文件被重写的index.html这是的public_html着,当然。任何帮助,请...

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...

删除斜线从你的正则表达式匹配的URI:

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 是每个目录指令和Apache条从重写规则 URI的当前目录路径(从而导致斜线)格局。
    • .htaccess is per directory directive and Apache strips the current directory path (thus leading slash) from RewriteRule URI pattern.