patnz
patnz

Reputation: 1141

Mod Rewrite allow one directory redirect all other traffic

I have a domain which is currently redirecting all traffic to another domain but I want to set up a sub directory on the first domain and allow traffic to that sub directory while continuing to redirect all other traffic. The rewrite directives currently in use are as follows:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^firstdomain.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.firstdomain.com.au$
RewriteRule ^(.*)$ "http\:\/\/www\.seconddomain\.com\/$1" [R=301,L]

I want to be able to access anything in a subdirectory www.firstdomain.com.au/wp/

Is there a simple solution? Thanks in advance.

Upvotes: 0

Views: 471

Answers (1)

anubhava
anubhava

Reputation: 785098

Try this rule in your .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?firstdomain\.com\.au$ [NC]
RewriteCond %{REQUEST_URI} !^/wp/ [NC]
RewriteRule ^(.*)$ http://www.seconddomain.com/$1 [R=301,L]

Upvotes: 1

Related Questions