I have a wordpress site that is accepting domain.com, but not www.domain.com.
my httpd.conf looks like:
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot "/var/www/html/domain"
</VirtualHost>
my .htaccess looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and my wp-config.php has the below:
define('WP_HOME','http://domain.com');
define('WP_SITEURL','http://domain.com');
yes. I changed the domain name. How do I get it to accept www.domain.com in addition to domain.com. If a user goes to www.domain.com, every page loses their logged in status and logs them out.
Thanks.
One way you could get it to allow both or any domains would be to do this in your wp-config.php file:
// Allows logins to persist across any subdomain:
define( 'COOKIE_DOMAIN', '.domain.com' );
// Sets home URL dynamically based on how site is accessed:
if ($_SERVER['HTTP_HOST'] == 'domain.com') {
define('WP_HOME','http://domain.com');
define('WP_SITEURL','http://domain.com');
}
if ($_SERVER['HTTP_HOST'] == 'www.domain.com') {
define('WP_HOME','http://www.domain.com');
define('WP_SITEURL','http://www.domain.com');
}
Here's more info on setting the cookie domain name option.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.