skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    I've actually solved it by using SEO Redirection Premium plugin for Wordpress.

    enter image description here

    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.

    enter image description here


  2. Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
    The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteRule (.*) https://www.newdomain.com/$1 [R=301,L]
    

    Please REPLACE www.newdomain.com in the above code with your actual domain name.

    In addition to the redirect I would suggest that you contact every backlinking site to modify their backlink to point to your new website(For SEO).

    Note* This .htaccess method of redirection works ONLY on Linux servers having the Apache Mod-Rewrite moduled enabled.

    And Then for http to https :

    RewriteCond %{HTTP_HOST} ^domain.com.au$ [OR]
    
    RewriteCond %{HTTPS} !on
    
    RewriteRule ^(.*)$ https://www.domain.com.au/$1 [R,L]
    

    And additionally you also can add the below code in wp-config.php

    define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
    
    define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
    

    Note*: This may not work for you not tried, but you should try once and let me know.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search