我最近升级的静态站点到CMS,我想老网站的所有html文件重定向到该站点的根目录(http://www.url.com),而不会影响CMS PHP。
I've recently upgraded a static site to a CMS and I'd like to redirect all the html files of the old site to the site's root (http://www.url.com), without affecting the CMS' PHP.
目前htaccess的看起来像这样
Current htaccess looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
显然,无论新规则我想补充不得与此相冲突。
Obviously whatever new rules I add mustn't conflict with this.
我想旧文件(url.com/page.html)重定向到url.com。
I'd like old files (url.com/page.html) to redirect to url.com.
我试图寻找,但没有任何工程之后的几件事情。任何帮助AP preciated。
I've tried a few things after searching but nothing works. Any help appreciated.
您需要将之前您的CMS规则添加这些规则
You need to add these rules before your CMS rules:
RewriteEngine On
# check that the request isn't for a legitimate existing resource
RewriteCond %{REQUEST_FILENAME} !-f
# redirect the .html request to the site root
RewriteRule ^(.*).html$ / [L,R=301]
上一篇:URL重写:如何改写2网址与参数相同的号码?重写、号码、参数、网址
下一篇:解析巴布亚新几内亚通过htaccess的PHP仅适用于本地服务器,但不是在网络服务器巴布亚新几内亚、服务器、是在、适用于