301 the right way to redirect a directory

I was wondering what would be the right way to do a redirect like this:

Redirect 301 /about/$ http://domain.com/new-about/ Redirect 301 /about$ http://domain.com/new-about/ Redirect 301 /about/me http://domain.com/new-about/ 

How am I doing this now, and it works, but I believe there should be a better way?

I have 2 pages that are rewritten, one page is a subpage of the other page /about/me/ , now both pages should redirect to a new page new-about

+4
source share
2 answers

You must either use RedirectMatch or use mod_rewrite to execute the regular expression. This should work and be the shortest and best solution:

 RedirectMatch 301 ^/about /new-about/ 

The domain and protocol are optional β€” leaving them as they are will keep them as they were, so this will be proof in the future.

+3
source

Some time has passed since I asked this question, and now regular expressions are more convenient for me.

Now I would do this:

 Redirect 301 ^/about http://domain.com/new-about/ 

The tool that helped me understand a lot of regular expressions, and which I would advise anyone trying to understand them, is Rubular: http://rubular.com/

0
source

All Articles