简体   繁体   English

301重定向.htaccess中的尾随斜杠

[英]301 redirect a Trailing Slash in .htaccess

I have a wordpress site. 我有一个wordpress网站。

This code redirecting www.site.com/category/ to www.site.com/category for duplicate content. 此代码将www.site.com/category/重定向到www.site.com/category以获取重复的内容。

but www.site.com/wp-admin/ doesn't work. 但www.site.com/wp-admin/不起作用。 How do I fix it? 我如何解决它?

RewriteRule ^(.*)/$ $1 [R=301]

I solved the problem. 我解决了问题。

is this code safe? 此代码安全吗?

RewriteCond %{REQUEST_URI} !^/wp-admin/
RewriteRule ^(.*)/$ $1 [R=301]

In this case you must have to access via FTP client like FileZilla or login to your hosting cPanel. 在这种情况下,您必须通过FTP客户端(如FileZilla)访问或登录到托管cPanel。

You can try the following code : 您可以尝试以下代码:

** **

ROptions +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/ $1 [R=301,L] ROptions + FollowSymLinks RewriteCond%{HTTP_HOST}上的RewriteEngine ^ example.com [NC] RewriteRule ^(。*)$ http://www.example.com/ $ 1 [R = 301,L]

** **

Reference: http://kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs 参考: http : //kb.mediatemple.net/questions/85/Using+.htaccess+rewrite+rules#gs

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

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