Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex htaccess重写是否始终在子文件夹中包含www?_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Regex htaccess重写是否始终在子文件夹中包含www?

Regex htaccess重写是否始终在子文件夹中包含www?,regex,apache,.htaccess,mod-rewrite,Regex,Apache,.htaccess,Mod Rewrite,是否可以编辑htaccess以始终在某个子文件夹中使用www?我找到了对整个目录执行此操作的选项,但找不到对子目录执行此操作的任何方法。您可以在root中使用此规则。htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(folder1|folder2)/ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,NC] 这只会影响在域名中添加www

是否可以编辑htaccess以始终在某个子文件夹中使用www?我找到了对整个目录执行此操作的选项,但找不到对子目录执行此操作的任何方法。

您可以在root中使用此规则。htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(folder1|folder2)/ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE,NC]

这只会影响在域名中添加
www
folder1
folder2

不幸的是,我不得不等了几个小时。我刚回来,已经回来了。