简体   繁体   English

301将所有页面和发布网址从.html重定向到/

[英]301 Redirect all page and post urls from .html to /

I have a current site which got all URLS end with .html. 我有一个当前站点,所有URL都以.html结尾。

I created a new site and the URLS are pretty much the same but without .html. 我创建了一个新站点,URL几乎相同,但是没有.html。

I've been trying codes found here in my .htaccess file and most seem to cause Internal Server Error. 我一直在尝试在我的.htaccess文件中找到的代码,并且大多数似乎导致内部服务器错误。

http://example.com/page1.html to http://example.com/page1/
http://example.com/page1/page2.html to http://example.com/page1/page2/

My current htacces file code is: 我当前的htacces文件代码为:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

You can install Simple 301 Redirect plugin and try to setting like image below. 您可以安装Simple 301 Redirect插件,然后尝试设置如下图所示的图像。 Just tested on my live site and it's running exactly what you want. 刚刚在我的实时网站上进行了测试,它可以完全按照您的要求运行。

Remember you checked Use wildcards? 还记得您选中了Use wildcards? checkbox too. 复选框。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM