字preSS的.htaccess WWW。不逼 [英] Wordpress .htaccess www. not forcing

查看:143
本文介绍了字preSS的.htaccess WWW。不逼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图迫使WWW。在我的网站的所有页面。 我有我的主网站(/博客)的文件夹中字preSS安装。在/博客文件夹中有一个.htaccess文件与以下内容:

I'm trying to force www. on all the pages of my site. I have wordpress install in a folder on my main site (/blog). In the /blog folder there is an .htaccess file with the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

在该网站的主目录。我有一个.htaccess文件具有如下:

In the main dir of the site. I have a .htaccess file that has the follow:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.sitename.com [NC]
RewriteRule (.*) http://www.sitename.com/$1 [R=301,L]
RewriteRule ^blog/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)$ /blog/index.php [L]

在字preSS是可以选择的WWW设置。在WWW。当我直奔出现,除了在每一页上的site.com/blog地址

In wordpress is have the option set for www. The www. appears on every page except the when I go straight the the site.com/blog address

推荐答案

进入设置 - >通用: 字preSS地址(URL) 网站地址(URL)

Go Settings -> General: WordPress Address (URL) Site Address (URL)

和他们都设置为www.yoursite.com(而不是yoursite.com),字preSS自动将负责所有的URL设置为www.yoursite.com,仅此而已。

And set both of them to www.yoursite.com (instead of yoursite.com), wordpress automagically takes care for setting all the urls to www.yoursite.com and that's it.

如果这还不够,你不应该编辑.htaccess文件,无论如何,因为任何时候你保存或重新加载您的永​​久链接设置,字preSS将覆盖您.htaccesss(一些插件可以做到这一点为好) 。

If that isn't enough, you shouldn't edit the .htaccess file anyway, because anytime you save or reload your permalink settings, Wordpress will overwrite your .htaccesss (some plugins may do that as well).

如果你想重写你的网址,你应该 WP重写($ C $做到这一点CX),或者如果你想一点更简单的办法,有一个很好的插件调用重定向(字press.org插件目录)

If you do want to rewrite your URL, you should do it with WP Rewrite (Codex), or if you want a little more simple approach, there is a good plugin for that called Redirection (Wordpress.org Plugin Directory).

在重定向插件,你可以只设置选项* .mydomain.com / *重定向到www.mydomain.com/*~~V和301,并会照顾你的htaccess的,只要你保持积极的插件

In Redirection plugin you can just set the options to *.mydomain.com/* to redirect to www.mydomain.com/* with a 301, and that will take care of your htaccess as long as you keep the plugin active.

希望这有助于:)

这篇关于字preSS的.htaccess WWW。不逼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆