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]

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 - 2019 Virtual Helpme | Techical Support and Maintenance | Original Template: Allrounder