Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to 301 redirect with or without the trailing slash?

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

like image 331
Cris Avatar asked Nov 02 '11 16:11

Cris


1 Answers

You want the expression to see the / as optional

^login/?$

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

like image 194
John Giotta Avatar answered Sep 21 '22 14:09

John Giotta