Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

Redirect all except one directory in Apache

PrintE-mail

Q. I would like to redirect all but one directory in Apache. How do I do that?

A. The process is very simple, using mod_rewrite:

Let's say that "directory1" is what you would like to continue using and everything else is to be redirected:

RewriteCond $1 !^directory1
RewriteRule (.*) https://www.example.com/$1 [R=301,L]

You can add as many RewriteCond as needed (so it can be more than just one directory). 

RewriteEngine on RewriteCond $1 !^archive RewriteRule (.*) https://www.mydomain.com/$1 [R=301,L]
Comments (1)
Thanks
1 Monday, 09 December 2019 11:07
Paul
MAN!!!!!!!!
I ran around all internet trying to find this. Any code i found worked for me.
Ty so much for your time to do so!
yours worked completaly fine.!!

Add your comment

Your name:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification:
yvComment v.1.24.0
   
Copyright © 1999 - 2020 Virtual Helpme | IT Services Catered to Your Business | Original Template: Allrounder