简体   繁体   English

.htaccess 301重定向

[英].htaccess 301 redirect

I switched my website from MODx to Wordpress to a different platform so now I have to make a 301 redirect. 我将网站从MODx切换到了Wordpress,并切换到另一个平台,因此现在我必须进行301重定向。

All I need to do is to 301 Redirect http://www.domain.com/page-name.html to http://www.domain.com/page-name/ . 我需要做的只是301将http://www.domain.com/page-name.html重定向到http://www.domain.com/page-name/

What lines should I add to my Wordpress .htaccess file? 我应该在Wordpress .htaccess文件中添加哪些行?

.htaccess file .htaccess文件

# 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

For just one page, try: 仅一页,请尝试:

Redirect 301 /page-name.html /page-name/

For everything ending with html, try: 对于以html结尾的所有内容,请尝试:

RedirectMatch 301 ^/([^.]+)\.html$ /$1/

请注意,完整的URL不起作用,只能使用相对URL

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

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