htaccess的重定向非www到www,除了特定的子目录子目录、重定向、htaccess、www

由网友(且行且安)分享简介:我要重定向所有example.com到www.example.com除了example.com/subdirectory应该保持原样,没有任何重定向。I need to redirect all example.com to www.example.com except for example.com/subdire...

我要重定向所有example.com到www.example.com除了example.com/subdirectory应该保持原样,没有任何重定向。

I need to redirect all example.com to www.example.com except for example.com/subdirectory which should remain as is without any redirection.

推荐答案

我已经通过在.htaccess文件下面的解决了这个问题。

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

RewriteEngine叙述在

RewriteEngine On

的RewriteCond $ 1!^子目录 的RewriteCond%{HTTP_HOST}!^ www.example.com $ [NC] 重写规则^(。*)$ http://www.example.com/ $ 1 [L,R = 301 ]

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

阅读全文

相关推荐

最新文章