Reputation: 27048
i have a website and it was working fine if i use example.com
or example.com/wp-admin
but was not working if i use www.example.com
or www.example.com/wp-admin
i redirected example.com
to www.example.com
and now neither www.example.com/wp-admin
or example.com/wp-admin
dont work. i get a blank page
here is what i got so far:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
any ideas on how to redirect everything but www.example.com/wp-admin
??
thanks
Upvotes: 1
Views: 2229
Reputation: 749
Are you sure the problem is the re-write rules? It sounds like www.example.com never worked.... and now you are redirecting everything to www.example.com, so nothing works. You might want to make sure your DNS / virtual host is set up properly... www can be set up to be different than non-www.
However, to answer yoru question, just add an additional condition.
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp-admin [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Upvotes: 5