开发者

.htaccess redirect non-www to www except for a particular subdirectory

开发者 https://www.devze.com 2023-01-01 21:53 出处:网络
I need to redirect all example.com to www.example.com except开发者_JAVA技巧 for example.com/subdirectory which should remain as is without any redirection.I have solved the problem by having the follo

I need to redirect all example.com to www.example.com except开发者_JAVA技巧 for example.com/subdirectory which should remain as is without any redirection.


I have solved the problem by having the following in the .htaccess file

RewriteEngine On

RewriteCond $1 !^subdirectory RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

0

精彩评论

暂无评论...
验证码 换一张
取 消