将pushstate支持的URL重定向到.html url

时间:2013-11-14 09:55:31

标签: regex apache .htaccess mod-rewrite pushstate

我正在使用html5 pushState(),但如果我想通过pushState URL加载网站,则返回404.

因此我需要将所有/ somePushStateURL重写为/somePushStateURL.html才能到达正确的站点。

正确的htaccess条目如何? 我的问题还有其他一些解决方案吗?

1 个答案:

答案 0 :(得分:1)

将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteCond %{REQUEST_URI} !\.html$ [NC]
RewriteRule ^(.+?)/?$ /$1.html [L,R]