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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:26:08+00:00 2026-06-08T17:26:08+00:00

This question attempts to combine knowledge gained from some previous answers on SO, so

  • 0

This question attempts to combine knowledge gained from some previous answers on SO, so do not mark as a duplicate unless the answer is meets the all of criteria about to be given.

This is what I want to do:
I need to temporarily .htaccess redirect visitors to my site to a clone copy so that I can make modifications on the existing site.
Therefore, I have the following needs:
1. All users requests /(.*) should be redirected to sub-directory /website/$1 (ie if someone requests /index.php it should go to /website/index.php)
2. If the user is from one of three specific ips the request should not be redirected, and should go to the file (ie if I request /index.php it should go to /index.php)
3. Said redirection should also force the use of www (ie requests with or without www, should be redirected to http://www.example.com/website)
4. Said redirection should be a temporary redirect of some sorts (the normal site will only be down for a couple of days)

This is my current code:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/website\/" [R=301,L]

It meets criteria 1,3, and 4. I just need help adjusting it to not redirect the three specific ip addresses.

Any thoughts as to how to incorporate #2?

  • 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-08T17:26:09+00:00Added an answer on June 8, 2026 at 5:26 pm

    How about:

    RewriteEngine On
    
    # for #2
    RewriteCond %{REMOTE_ADDR} !123\.45\.67\.89$
    RewriteCond %{REMOTE_ADDR} !123\.45\.67\.90$
    
    # for #1 and #3 and #4
    RewriteCond %{REQUEST_URI} !^/website/ [NC]
    RewriteRule ^(.*)$ http://www.example.com/website/$1 [R=302,L]
    

    For #2 you want to replace the 123\.45\.67\.89 etc with the IP addresses that you want not to be redirected.

    For #4, the R=301 needed to be changed to R=302

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

Sidebar

Related Questions

Ok this question stems from this question: wp7: App failing! Can not figure out
This is a very basic question, but my brain isn't working and multiple attempts
I've decided to take the advice in this question: create-excel-chart-programmatically-in-php and NOT attempt to
This question is related to a previous question I asked, but it's a different.
I half realize that this question is probably asked already, but I'm not familiar
I would like to hook into this question, however perhaps rephrase it from a
I have this question on the Wordpress stack exchange as well, but not having
Note : This question has been re-asked with a summary of all debugging attempts
This question on getting random values from a finite set got me thinking... It's
This question is a result of what i noticed while trying to answer another

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.