Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9047253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:51:58+00:00 2026-06-16T11:51:58+00:00

Possible Duplicate: .htaccess rewrite to redirect root URL to subdirectory I need to change

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:52:00+00:00Added an answer on June 16, 2026 at 11:52 am

    You can redirect them to the new Location with

    header('Location: /blog' . $_SERVER['PHP_SELF']);
    

    If you use PHP version >= 5.4.0, you can also send a proper HTTP status code 301 (moved permanently) with

    http_response_code(301);
    

    When you want to use .htaccess you can redirect with RewriteCond and RewriteRule.

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/blog/
    RewriteRule .* /blog$0 [L,R=301]
    

    The RewriteCond directive prevents rewriting URLs, which already start with /blog. Otherwise you will get an endless recursion.
    The RewriteRule directive prefixes all URLs with /blog, doesn’t apply further rules L and sends HTTP status code 301 R=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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Rewrite all queries to not need the .php extension using a mod_rewrite
Possible Duplicate: .htaccess RewriteRule for Flat Links i have a problem in a rewrite
Possible Duplicate: Redirect *.htm to *.php htaccess rewrite if redirected file exists I set
Possible Duplicate: .htaccess rewrite image file to php script How can I execute a
Possible Duplicate: How to add .php extension using .htaccess url rewriting? I want to
Possible Duplicate: Apache rewrite based on subdomain Is it possible to rewrite a URL
Possible Duplicate: How to identify if referrer is a 301 redirect Using htaccess Im
Possible Duplicate: htaccess rewrite breaks relative paths I am hoping someone can help me.
Possible Duplicate: Please URL Rewrite in php I would like visitors to access the
Possible Duplicate: .htaccess redirect How exactly, with a .htaccess file i'm presuming, would i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.