How to 301 redirect with or without the trailing slash?

廉价感情. 提交于 2019-12-12 08:28:09

问题


I want to redirect site.com/login OR site.com/login/ to site.com/wp-login.php

Here's what I have so far:

RewriteRule ^login$ "\/wp\-login\.php" [R=301,L]

But it doesn't redirect /login/ (with the trailing slash). How to tell htaccess to redirect with or without the trailing slash?

Thank you, Cris


回答1:


You want the expression to see the / as optional

^login/?$

The ? token will allow for the zero or one occurence of the /



来源:https://stackoverflow.com/questions/7983726/how-to-301-redirect-with-or-without-the-trailing-slash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!