I've Wordpress site with WPML installed. I've done 2 things recently:
This is done to improve SEO. However while I got that working without much problem using:
# BEGIN HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} ^80$
#RewriteCond %{HTTPS} !^on$
#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
</IfModule>
# END HTTPS
# 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
In apache.conf file ServerName domain.xyz, ServerAlias domain.pl www.domain.pl
and so on. I'm having problems with most of my old blog posts that are around the internet in different forms. For example:
It seems that last / is making huge difference.
I've planned to add all redirects in even direct form 1 to 1 to new domain but since it's partially working, partially not I'm kind of lost... and I am not sure how I could translate them correctly.
EDIT:
I've tried multiple options, even one that supposedly rewrites all links to end with / and it still fails.
# BEGIN HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#RewriteCond %{SERVER_PORT} ^80$
#RewriteCond %{HTTPS} !^on$
#RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
#RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
#RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
#RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !^on$
#RewriteRule (.*) https://evotec.xyz/$1 [R=301,L]
#RewriteRule (.*) https://%{SERVER_NAME%}/$1 [R=301,L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_URI} !(.*)/$
#RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|js)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]
</IfModule>
# END HTTPS
Another update:
So it's not entirely not working for all slash vs non-slash. It's more about translation of some sort that doesn't happen if it points to old domain.
I've tried using Redirect Checker to see how it works (on proper example) but I can't make any meaning from it.
http://evotec.pl/hub/scripts/office365-addbulkemailaddressses-ps1 301 Moved Permanently https://evotec.pl/hub/scripts/office365-addbulkemailaddressses-ps1/ 301 Moved Permanently https://evotec.xyz/hub/scripts/office365-addbulkemailaddressses-ps1/ 200 OK
http://evotec.pl/hub/scripts/office365-addbulkemailaddressses-ps1/ 301 Moved Permanently https://evotec.xyz/hub/scripts/office365-addbulkemailaddressses-ps1/ 200 OK
https://evotec.pl/hub/scripts/office365-addbulkemailaddressses-ps1 404 Not Found
The more options I try the weirder it gets. While the RedirectChecker seems to be showing one thing ... browser is behaving a bit different and doesn't work for the first entry anyways causing 404 straight away
Edit:
If I leave only "Wordpress" data following is true:
It only works properly if i use the correct/new domain then all works properly:
I guess if I can't redirect it, i will leave it as it is and just give up.
Improper syntax being used It is quite common for a syntax error to be the reason for an . htaccess file not working. If you are familiar with how to read and configure . htaccess rules, double check your configuration.
Use a 301 redirect . htaccess to point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain.
Save the file and type the URL yoursite.com/foobar/ . If the reditect works and the URL gets redireted to the homepage of example.com then it's clear that your htaccess is working and being read by your Apache server. If it still doesn't work then the problem might be that your hosting provider has not enabled it.
htaccess files follow the same syntax as the main configuration files. Since . htaccess files are read on every request, changes made in these files take immediate effect.
I've actually solved it by using SEO Redirection Premium plugin for Wordpress.
It's able to redirect broken links without /. In this case I've done it manually but I'm working on a way to do it in more global way with Regex. Just need to find proper one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With