admin管理员组文章数量:1122826
I have a current site where all URLs end with .html
.
I created a new site and the URLs are pretty much the same but without .html
.
I've been trying codes found here in my .htaccess
file and most seem to cause Internal Server Error.
.html to /
.html to /
My current .htaccess
file code is:
# 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
I have a current site where all URLs end with .html
.
I created a new site and the URLs are pretty much the same but without .html
.
I've been trying codes found here in my .htaccess
file and most seem to cause Internal Server Error.
http://example.com/page1.html to http://example.com/page1/
http://example.com/page1/page2.html to http://example.com/page1/page2/
My current .htaccess
file code is:
# 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
Share
Improve this question
edited Sep 24, 2017 at 15:05
MrWhite
3,8911 gold badge20 silver badges23 bronze badges
asked Sep 24, 2017 at 13:16
AtashaAtasha
2431 gold badge3 silver badges10 bronze badges
1 Answer
Reset to default 0Just to note, when you get an Internal Server Error (code 500), you should check your server's error log for the specifics of the error. If you've been messing with mod_rewrite in .htaccess
then this could be anything from a basic syntax error to a rewrite loop.
If you have no .html
files on your new site then you can issue an unconditional redirect to remove the .html
on the end of the URL. For example:
RewriteRule (.*)\.html$ /$1 [R=301,L]
This would need to go before the existing WordPress directives.
Or, if you do have some .html
files that need to be served as-is then only redirect requests that do not map to an existing file. For example:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)\.html$ /$1 [R=301,L]
You will need to clear your browser cache before testing.
本文标签: htaccess301 Redirect all page and post urls from html to
版权声明:本文标题:htaccess - 301 Redirect all page and post urls from .html to 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736291973a1928836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论