herci
herci

Reputation: 385

How to redirect the old URLs to new one (root->subdirectory)?

There is a website on the domain root: example.com

Then I had to move it to example.com/new

What I want to do is to redirect all old URLs to new ones but not the root domain (example.com) itself. I mean if a visitor visits the example.com it shouldn't be redirect but if he visits a subpage such as example.com/login he should be redirected to the new URL (example.com/new).


These are the examples:

example.com/login -> example.com/new/login

example.com/page/about -> example.com/new/page/about

example.com/page/about/contact -> example.com/new/page/about/contact


But example.com/new/something shouldn't be redirect to example.com/new/new/something


How can I do this with .htaccess file?

Upvotes: 0

Views: 35

Answers (1)

Joe
Joe

Reputation: 4897

You would just use Redirect 301:

Redirect 301 /login.html http://example.com/new/login.html
Redirect 301 /page/about.html http://example.com/new/page/about.html

These are permanent redirects. Make sure it is a perm and not temp redirect you want to do. If it was a temporary redirect, you would use Redirect 302.

Upvotes: 1

Related Questions