Rewrite all files from newfolder to index.html

吃可爱长大的小学妹 提交于 2020-01-15 11:03:14

问题


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) from RewriteRule URI pattern.


来源:https://stackoverflow.com/questions/21676105/rewrite-all-files-from-newfolder-to-index-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!