[英]Redirect all requests to main page using htaccess (hide index.html in URL)
我想将所有请求重定向到主页(index.html)。 状态栏中的网址不应显示index.html。 目前,我正在使用以下代码,该代码重定向到index.html并将其显示在URL中:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/index.html$ RewriteCond %{REQUEST_URI} !.(gif|jpeg|png|css|js)$ RewriteRule .* /index.html [L,R=302]
我应该进行哪些更改以使其按预期工作? 谢谢!
尝试:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(index.html)?$
RewriteCond %{REQUEST_URI} !.(gif|jpeg|png|css|js)$
RewriteRule .* / [L,R=302]
如果它按预期工作,除了浏览器的外部重定向外,您只需要删除R = 302标志,该标志告诉服务器发送302标头。
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !.(gif|jpeg|png|css|js)$
RewriteRule .* /index.html [L]
并检查DirectoryIndex
指令,以默认显示index.html(如果已更改)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.