[英]Exclude folder in htaccess from www redirect
I have a www redirect in my .htaccess: 我的.htaccess中有一个www重定向:
RewriteCond %{HTTP_HOST} example\.com
RewriteRule ^(.*)$ http://www.example/ [R=permanent]
Now I would like to exclude one folder to use the above redirect. 现在,我想排除一个文件夹来使用上述重定向。 I would like to access a folder without being redirected to the domain with www. 我想访问一个文件夹而不用www重定向到域。 For example: What I want: example.com/test What happens: www.example.com/test 例如:我想要的:example.com/test发生的事情:www.example.com/test
Can I exclude only the folder test? 我可以只排除文件夹测试吗?
You can use: 您可以使用:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule !^test/ http://www.%{HTTP_HOST}/%{REQUEST_URI} [L,NC,NE,R=302]
Make sure this rule is first rule just below RewriteEngine On
line your root .htaccess (one directory level above /test/
). 确保此规则是RewriteEngine On
下方的第一条规则。 RewriteEngine On
您的根.htaccess行( /test/
上方的一个目录级别)上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.