Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache 我的htaccess文件中的www和非www解析问题_Apache_.htaccess - Fatal编程技术网

Apache 我的htaccess文件中的www和非www解析问题

Apache 我的htaccess文件中的www和非www解析问题,apache,.htaccess,Apache,.htaccess,我有一个网站,我想解决万维网和非万维网的问题。我试图从.htaccess文件中使用下面的代码。但没有结果 RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.w15.lk%{REQUEST_URI} [R=301,L,NE] # Remove Trailing Slashes... RewriteCond %{REQUEST_

我有一个网站,我想解决万维网和非万维网的问题。我试图从.htaccess文件中使用下面的代码。但没有结果

RewriteEngine On
RewriteCond %{HTTPS} off [OR]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.w15.lk%{REQUEST_URI} [R=301,L,NE]

# Remove Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s(.+?)/+[?\s]
RewriteRule ^(.+?)/$ /$1 [R=301,L,NE]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

你的尝试很接近。请尝试使用以下方法:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.w15.lk/$1 [L,R=302,NC]
我已经将R标志设置为302,使其成为测试的临时重定向。如果可以,请将其更改为301以使其永久化


在测试之前,请不要忘记清除缓存。

网站serverfault.com是提出此类问题的更好地方。我已进行了更改和测试。但结果是一样的。有什么想法吗