Home add www in URL if no subdomain but exception with some folders
Reply: 0

add www in URL if no subdomain but exception with some folders

user730
1#
user730 Published in June 20, 2018, 7:37 am

I want to add "www." to URLs if it doesn't contain "www." after "http://"; but it shouldn't get added if any file is requested from some specific folders.

Here is what I have tried.

RewriteEngine On
RewriteCond %{PATH_INFO} ^/exception_dir(.)*$
RewriteRule ^(.*)$ - [L]

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]

With this code, presently, the "exception_dir" is NOT being exempted from redirection. What I am missing?

And how to write RewriteCond and/or RewriteRule if there are multiple directories to be exempted? Do I need to write both RewriteCond and RewriteRule for each of the directories separately?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312165 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO