user608528
user608528

Reputation: 21

Force www for specific subfolders

I would like to add a Rewrite condition in order to keep www on all admin pages and on update.php

I tried to make a condition like in the following to exclude admin but without succes...

 RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]

 RewriteCond %(REQUEST_FILENAME) !^admin$

 RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

maybe one of you can help me sorting out this? I'm unfortuately not so familiar with mod rewrite...

Thanks to all of you

Herve

Upvotes: 2

Views: 184

Answers (2)

Ahmad Moussa
Ahmad Moussa

Reputation: 1324

if(strpos($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'],'www')===false)
 header('location:'.'http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']  ); ?>

Upvotes: 0

Gumbo
Gumbo

Reputation: 655489

Try this condition instead of your second condition:

RewriteCond %(REQUEST_URI) !^/(admin($|/)|update\.php$)

Upvotes: 2

Related Questions