rciiipo
rciiipo

Reputation: 863

mod_rewrite everything except two URLs

I am trying to rewrite everything EXCEPT the below two urls to google.com (could be any external url, but google for testing).

w3ink.com/wp/folder/wp-admin  
w3ink.com/wp/folder/schedule-the-truck

goes to pages on site.

everything else goes to google.com

Here's what I have so far in my .htaccess file in documentRoot:

RewriteCond %{REQUEST_URI} !^/wp/folder/schedule-the-truck$  
RewriteCond %{REQUEST_URI} !^/wp/folder/wp-admin$  
RewriteRule .* "http://google.com" [R=301,L]

It just doesn't work. Everything gets forwarded to google.com, even the two pages in my negative condition statements.

Upvotes: 0

Views: 966

Answers (2)

PleaseStand
PleaseStand

Reputation: 32082

Try removing the $ at the end of the rewrite conditions.

Because wp-admin is a directory, the server redirected to wp-admin/. Then your rewrite rule redirected that to http://www.google.com/.

Upvotes: 0

Roland Illig
Roland Illig

Reputation: 41625

You should enable the mod_rewrite debug logging. This might probably show you that for .htaccess files, the REQUEST_URI does not start with a slash. (And even if my assumption is wrong, it will show you all steps that happen, which should give you a hint to why they happen.

Upvotes: 1

Related Questions