php - Accessing wordpress multisite without www. sets the site url multiple times in browser bar -
when access domain: www.example.com without www. site automatically loop site url multiple times in browser bar.
in browser bar before hitting enter:
example.com
after hitting enter:
www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/
this works fine:
www.example.com
i've set wordpress multisite network 3 domains.
i have code in wp-config.php file
define('wp_allow_multisite', true); define('multisite', true); define('subdomain_install', true); define('domain_current_site', 'www.example.com'); define('path_current_site', '/'); define('site_id_current_site', 1); define('blog_id_current_site', 1); define('noblogredirect', 'www.example.com/'); /* had set because redirected login page every time */ define('admin_cookie_path', '/'); define('cookie_domain', ''); define('cookiepath', ''); define('sitecookiepath', '');
my .htaccess file:
# begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule>
rewriteengine on rewritecond %{http_host} ^[0-9a-za-z-]+\.[a-za-z]{2,}$ rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]
rewritebase / rewriterule ^index\.php$ - [l] # add trailing slash /wp-admin rewriterule ^wp-admin$ wp-admin/ [r=301,l] rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l] rewriterule ^(wp-(content|admin|includes).*) $1 [l] rewriterule ^(.*\.php)$ $1 [l] rewriterule . index.php [l] # end wordpress
i've put highlighted line of code in .htaccess file to
- force every access go https version of website
- won't redirect when accessing specific subdomain:
with this, got rid of www. error error persists when set behind slash example:
in browser bar before hitting enter:
example.com/abc
after hitting enter:
www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/
this works fine:
www.example.com/abc
anything 1 character word causes looping domain error...
edit: changing these 2 lines in wp-config.php to:
define('domain_current_site', 'example.com'); define('noblogredirect', 'example.com');
will place domain 2 times in browser bar, looks this:
in browser bar before hitting enter:
example.com/abc
after hitting enter:
www.example.com/www.example.com/
Comments
Post a Comment