Wordpress.htaccess www. not coercion

I'm trying to get www. on all pages of my site. I have wordpress install in a folder on my main site (/ blog). There is a .htaccess file in the / blog folder 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> 

In the main directory of the site. I have a .htaccess file that has the following:

 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] 

Wordpress has an option set for www. Www. appears on every page, except when I go directly to site.com/blog

+7
source share
4 answers

Go Settings โ†’ General: WordPress Address (URL) Website Address (URL)

And install both of them on www.yoursite.com (instead of yoursite.com), wordpress automatically configures all the URLs on www.yoursite.com and what it is.

If this is not enough, you should by no means edit the .htaccess file, since at any time when you save or reload your permalink settings, Wordpress will overwrite your .htaccesss (some plugins can do this).

If you want to rewrite your URL, you must do it using WP Rewrite (Codex) , or if you want a slightly simpler approach, there is a good plugin for Redirection (Catalog of plugins Wordpress.org) .

In the Redirection plugin, you can simply set the parameters to * .mydomain.com / * to redirect to www.mydomain.com/* with 301, and this will take care of your htaccess if you keep the plugin active.

Hope this helps :)

+7
source
 RewriteCond %{HTTP_HOST} !^www\.(.*) RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L] 
+4
source

In the .htaccess installation of WordPress (/ blog / in your case) you can add the following code ABOVE the line that reads # BEGIN WordPress

 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC] RewriteRule ^(.*)$ "http\:\/\/www\.domain\.com\/subdirectory\/$1" [R=301,L] </IfModule> ## Redirect primary WordPress URL to WWW version 

Obviously, replace "domain.com" with the actual domain name and "subdirectory" with the name of the subdirectory in which WordPress is installed. (/ blog / in OP request).

+2
source

Do you have an option:

Log in to your wp-admin Go to "Settings โ†’" General In the "WordPress Address (URL) and" Site Address (URL) section, add www to the address as shown below

0
source

All Articles