Possible Duplicate:
.htaccess rewrite to redirect root URL to subdirectory
I need to change all the links(2455) in my site.
There will be a problem when visitors come from Google (using the old links) as the page will be 404 page not found
I want to redirect the old links to the new version of the page. For example:
Old links:
http://example.com/hotel/13234
http://example.com/hotel/132
http://example.com/hotel/323
http://example.com/page/about_us
http://example.com/page/contact
New links: (add “blog” ) after domain
http://example.com/blog/hotel/13234
http://example.com/blog/hotel/132
http://example.com/blog/page/about_us
http://example.com/blog/hotel/323
...
...
...
What is the best way to do this?
You can redirect them to the new
LocationwithIf you use PHP version >= 5.4.0, you can also send a proper HTTP status code 301 (moved permanently) with
When you want to use
.htaccessyou can redirect withRewriteCondandRewriteRule.The
RewriteConddirective prevents rewriting URLs, which already start with/blog. Otherwise you will get an endless recursion.The
RewriteRuledirective prefixes all URLs with/blog, doesn’t apply further rulesLand sends HTTP status code 301R=301.For this to work, these directives must be allowed in
.htaccess. You can use the same directives in your main conf file or in a virtual host context.