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 8432453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:07:50+00:00 2026-06-10T06:07:50+00:00

I have a domain oldexample.com, and I want to redirect users who visit that

  • 0

I have a domain oldexample.com, and I want to redirect users who visit that domain to newexample.com only when no parameters are given. In the case where parameters are supplied with the domain, it should redirect elsewhere – so, oldexample.com/?id=5 should not redirect to newexample.com, rather I want to redirect it to some internal directory in newexample.com, say to newexample.com/dir/5.

Here’s a summary of how I want the redirects to work:

oldexample.com -> newexample.com
oldexample.com/?id=3 -> newexample.com/dir/3
oldexample.com/index.php?id=6 -> newexample.com/dir/6

So how would I write the RewriteRules in htaccess to get this job done?

  • 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-10T06:07:52+00:00Added an answer on June 10, 2026 at 6:07 am

    Try:

    RewriteEngine On
    
    # for /
    RewriteCond %{HTTP_HOST} ^oldexample.com$ [NC]
    RewriteCond %{QUERY_STRING} !id=
    RewriteRule ^$ http://newexample.com/ [L,R=301]
    
    # for /?id=###
    RewriteCond %{HTTP_HOST} ^oldexample.com$ [NC]
    RewriteCond %{QUERY_STRING} ^id=([0-9]+)
    RewriteRule ^(index.php)?$ http://newexample.com/dir/%1? [L,R=301]
    

    The last rule matches against / and /index.php. These rules need to be in the htaccess file in your oldexampl.com document root.

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

Sidebar

Related Questions

I have a domain test.com and I want this domain to redirect to mydomain.com/test.
Think I have domain.com that redirects into some.otherdomain.com . I don't want to show
I have a domain name www.xyz.com and I want to make sure if someone
I have domain name for eq. 1) http://www.abc.com/search 2) http://go.abc.com/work I get only domain
I have one domain (domain.com) with multiple sub-pages that have different sessions (by default)
For example, I have domain name abc.com I want both abc.com and www.abc.com can
I have domain like: someword.com.s123234.gridserver.com I am trying to .htaccess redirect like RewriteEngine on
I have domain site.com and there is subdomain sub.site.com Once you open sub.site.com you
If I have domain name example.com , and if I set an A record
I have a domain with wildcard - *.mysite.com hosted on Server1 I am planning

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.