Redirect all except one directory in Apache
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).
Last Updated on Tuesday, 16 April 2013 11:56
Comments (1)
Add your comment
yvComment v.1.24.0
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.!!