multisite - URL without www redirect directly with submission page - Multiwordpress install

admin2025-06-04  3

This is a Wordpress related question, because the problem came from a multi-install Wordpress. But it's also related to serverside, with .htaccess

My problem is : when a user type my URL without WWW, it get him/her to an submission URL, inviting him/her to log-in. From to an URL like this .php?new=mister-tea.fr instead of

I really don't want it, I just want that the user is redirected to the same domain, and the same URL with WWW.

My main domain is (Fr website)

The rule could work :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fixie-lille.fr$
RewriteRule (.*) /$1 [R=301,L]
</IfModule>

But it breaks other website.

I tried using some rules in .htaccess, but does not seems to work. All my websites use WWW domains and are not available without WWW.

Beside that, I use this rule to redirect user between http and https

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Does the following rule could have a bad interference ?

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

Beside that, everything works fine wtih several Wordpress in just one install.

Thanks per advance, I'm at your disposal to answer further questions

This is a Wordpress related question, because the problem came from a multi-install Wordpress. But it's also related to serverside, with .htaccess

My problem is : when a user type my URL without WWW, it get him/her to an submission URL, inviting him/her to log-in. From https://mister-tea.fr to an URL like this https://www.fixie-lille.fr/wp-signup.php?new=mister-tea.fr instead of https://www.mister-tea.fr

I really don't want it, I just want that the user is redirected to the same domain, and the same URL with WWW.

My main domain is https://www.fixie-lille.fr (Fr website)

The rule could work :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fixie-lille.fr$
RewriteRule (.*) https://www.fixie-lille.fr/$1 [R=301,L]
</IfModule>

But it breaks other website.

I tried using some rules in .htaccess, but does not seems to work. All my websites use WWW domains and are not available without WWW.

Beside that, I use this rule to redirect user between http and https

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Does the following rule could have a bad interference ?

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

Beside that, everything works fine wtih several Wordpress in just one install.

Thanks per advance, I'm at your disposal to answer further questions

Share Improve this question asked Jun 25, 2018 at 10:20 Arthur CamberleinArthur Camberlein 134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Since you have multiple domains you can't include the domain in the redirect itself to create a one-size-fits-all generic redirect (which is what I assume you are trying to do). You also need to ensure that the directives are in the correct order.

Since all your sites use the www subdomain then try the following instead. However, this assumes you don't have any other subdomains.

RewriteEngine On

# non-www to www (and HTTPS)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]

# HTTP to HTTPS 
RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# WordPress directives follow...

The non-www to www redirect now tests if the requested host does not start www. And if not, simply prepends it.

No need to repeat the RewriteEngine directive and no need for the <IfModule mod_rewrite.c> wrappers on your custom directives.

With regards to your HTTP to HTTPS redirect, there's no need to capture the RewriteRule pattern if it is not being used in the substitution. ie. When using %{REQUEST_URI} instead of a backreference.

As always, clear your browser cache before testing.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749024717a315718.html

最新回复(0)