[英].htaccess Subfolder Redirect from http:// to www
I'm trying to push my subfolder from using http://example.com/chat to www.example.com/chat. 我正在尝试将子文件夹从使用http://example.com/chat推送到www.example.com/chat。 I've tried the following in my subfolder's .htaccess file with no luck.
我在子文件夹的.htaccess文件中尝试了以下操作,但没有成功。 It does not push the page to a www.
它不会将页面推送到www。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(subfolder(?:/.*)?)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]
Any help would be great. 任何帮助都会很棒。
You can use this in /subfolder/.htaccess
: 您可以在
/subfolder/.htaccess
使用它:
RewriteEngine On
RewriteBase /subfolder/
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 [L,QSA]
ie keep redirect rule before internal routing one and simplify your regex. 即在内部路由之前保留重定向规则,并简化您的正则表达式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.