does anyone have any idea, why my redirection from www to non-www might not work?
Basic Info: Strato Hoster, Worpress Domain redirection is working for: bitcoinmesse.com Sub-Domain redirection not working: shop.bitcoinmesse.com
Current .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
# 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>
# END WordPress
Tried so many different things, all through the web. Most of them lead to this:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Others just said I have an infinite loop:
Again others lead to weird errors, like requesting a subfolder likte /shop/ and either getting a 404 or a https://shop/ couldn't be reached.
But none of them redirected www to non-www. Entering the address with www just always lead to: Server not found in Firefox or Website not reachable in Chrome.
Anyone has any ideas?
EDIT: Meanwhile it seemed to have an effect, and www.shop.bitcoinmesse.com is reachable and forwards to https://shop.bitcoinmesse.com .
Unfortunately a subpage like www.shop.bitcoinmesse.com/shop/ is not reachable.
Try
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
Basically right now the back-reference $1
isn't pointing to anything. I added (.*)
to the RewriteRule
so that $1
actually was a reference to a capture group in the regex. You could also try just changing $1
to $0
and it would do the same thing since $0
is the full matched URL.
I also updated the RewriteCond to ensure that the host header has something after www.
. It's a minor change, since the server shouldn't be listening to any host header anyway.
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.