Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.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
在wordpress中将www重定向到非www_Wordpress_Apache_.htaccess_Ovh - Fatal编程技术网

在wordpress中将www重定向到非www

在wordpress中将www重定向到非www,wordpress,apache,.htaccess,ovh,Wordpress,Apache,.htaccess,Ovh,我已经将非www url添加到我的gerenal-setting-WordPress地址url和站点地址url中 并编辑了我的wordpress.htaccess,如下所示。但它仍然没有重定向到非www站点,知道为什么吗 <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteBase / # remove www RewriteCond %{HTTP_HOST} ^www\.(.+)$ [N

我已经将非www url添加到我的gerenal-setting-WordPress地址url和站点地址url中

并编辑了我的wordpress.htaccess,如下所示。但它仍然没有重定向到非www站点,知道为什么吗

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>
使用cPanel重定向到www或非www 将类型设置为永久,这将给出HTTP 301状态代码。 在此下拉列表中选择您的主域。 如果路径为空,则要重定向整个域。 指定要重定向到的URL,其中包含“www”部分。 选择“不重定向www”
您可以使用以下重写规则,即

RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
如果您不想使用Mod rewrite规则,则使用重定向,即

<VirtualHost 127.0.0.1:80>
        ServerName www.example.com
        Redirect permanent / http://example.com/
</VirtualHost>

询问者标记的是Apache,而不是cPanel。