Blogger To Wordpress Migration Issue - wordpress

I'm facing an issue after migrating my blog from Blogger to Wordpress.
My all old links are properly redirecting to WP but there are few 404 errors in my Google Webmaster Tools account.
For example: www.bloggertipstricks.com/2013/03/seo-tips.html?m=1
There is an extra parameter added after the URL (?m=1). Anybody please help me to resolve this issue.

Here I got solution for this. As you know that Blogger also ends with ?m=0 with ?m=1 so you have to remove both from URLs. So try the below codes by adding them in the top of .htaccess file...
You you can use the following code in any version:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^m=1$
RewriteRule ^(.*)$ /$1? [R=301,L]
RewriteCond %{QUERY_STRING} ^m=0$
RewriteRule ^(.*)$ /$0? [R=301,L]
In Apache 2.4 and above you can use the following:
RewriteCond %{QUERY_STRING} m=[01]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [QSD,R=301,L]
In lower version of Apache then 2.4 you can use the following:
RewriteCond %{QUERY_STRING} m=[01]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI}? [R=301,L]

Related

How to redirect all my website posts/pages from Http (+ www or non-www) to Https (non-www) URL

I recently updated my website from http to HTTPS & I don't have any prior knowledge about this. I did it following some articles on the internet & it was successful. My site is accessible through https & it's all fine.
But I'm stuck with redirecting the existing pages and posts. I'm not sure if I messed it up or I just don't know how to redirect properly.
Here's what I'm trying to do, I want to redirect all the URLs in the below format to redirect
from:
http://example.com/*
http://www.example.com/*
https://www.example.com/*
to
https://example.com/*
I've tried using the following code, but it's not helping.
# Canonical https/www
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule (.*) https://www.%1/$1 [R=301,L]
</IfModule>
Any help would be appreciated. Thanks a lot in advance.
Found the answer after carefully doing some troubleshooting. The issue is with ReallySimple SSL plugin I used while updating to https.
By default, the plugin is redirecting all the traffic to https://www.example.com format which is showing an error page.
So I made the changes as per my requirement.
The problem is I didn't notice that this code exists & I'm looking at a wrong htaccess file in root folder instead of the htaccess file in public_html file.
# BEGIN rlrssslReallySimpleSSL rsssl_version[3.3.1]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>
I hope this is helpful if someone faces similar issue.

How to use .htaccess to remove '?m=1' in the end of url?

I just moved my blog from Blogger to WordPress, and have a problem with the mobile URL.
WordpPress have a function to setup URL structure, so the URL for desktop is OK, but there is an additional ?m=1 in mobile version Blogger URL.
This is what I'm trying to do:
redirect http://www.example.com/2016/05/artical.html?m=1
to http://www.example.com/2016/05/artical.html
I tried this but it didn't work:
RewriteCond %{QUERY_STRING} ^(.*)(^|&)m=1(.*)$
RewriteRule ^(.*)$ /$1?%1%3 [R=301,L]
Hope this helps just after RewriteEngine On
RewriteCond %{QUERY_STRING} ^m=1$
RewriteRule ^(.*)$ /$1? [R=301,L]

Can't keep query string on URL

I run an Apache server with ISPConfig 3 installed and WordPress. I applied rewrite rules so that all HTTP goes to HTTPS and all WWW goes to non-WWW.
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [QSA,L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com$1 [QSA,L]
I put this in my WordPress htaccess, and the example.com.vhost file created by ISPConfig 3.
The problem is now, even with the QSA in the flags, the query string is removed. I have tried the flags:
[L,R]
[R=301,L]
[R=301,L,QSA]
[L,QSA]
[QSA,L]
I have checked apache2.conf, 000-default from ISPConfig, example.com.vhost, and .htaccess files for any rules that do not have QSA or R and have not found any.
I'm a RewriteRule novice, but I'm trying to wrap my head around this, what am I doing wrong?
EDIT: While in my WP dashboard, I noticed that query strings are present in the URLs. So while on the frontend my server drops the query string, on the backend the query string is preserved. So I'm thinking that the WordPress's .htaccess must be the issue, right?
Try with:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
Test for www before test with https
No need to add [QSA] if you do not add ? and new query string.
While experimenting never use the R=301 permanent redirect because it will make live very hard for you. With Firefox you need to delete the entire cache just to try again. A useful trick can be using the private navigation mode to test. Then at least you can ditch it and start up another one.
Query strings would be transferred automatically in a [R] redirect. Unless maybe there is some QSD before or you put a ? inside the RewriteRule.
Can you try it like this?
RewriteEngine on
RewriteCond %{HTTPS} ^off$
RewriteRule . https://example.com%{REQUEST_URI} [R,L]
RewriteEngine on
RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule . https://example.com%{REQUEST_URI} [R,L]

non-www to www redirect not working for articles in subdirectory installation of WordPress

I am helping out with a website that has a main/root website as well as a WordPress installation in a sub-directory. The .htaccess file of the main site has rules to redirect non-www traffic to www:
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule (.*) http://www\.site\.com/$1 [R=301,L]
However, this has no effect on the WP site. For instance:
site.com would redirect to www.site.com
site.com/some-content-belonging-to-root-site would redirect to www.site.com/some-content...
site.com/wordpress does not redirect to www.site.com/wordpress
I added similar rules to the WordPress .htaccess, playing around to try to get the result I would expect, but the best I could come up with is this:
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
...which successfully redirects site.com/wordpress to www.site.com/wordpress, but does not redirect site.com/wordpress/a-blog-post.
I feel like I must be missing something simple or obvious, but hours of experimentation and research have not yielded a thing except that .htaccess files in sub-directories are not advised (but I think this is unavoidable in this case).
I would be grateful for any suggestions on how to fix the rewrite condition or rule to successfully redirect the post links of the WP site.
Thanks!
EDIT / ADDITIONAL INFO: I modified the RewriteCond to better match the incoming URLs, thinking that this might help, but it has the same effect. The base wordpress URL is rewritten, but article URLs are not:
RewriteCond %{HTTP_HOST}/wordpress/.* ^site\.com/wordpress/.* [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
I wouldn't think that it should matter, but just in case, I'll mention that the article URLs look like this:
site.com/wordpress/2014/05/16/article-slug
It turned out that the problem was not the rewrite conditions or rules, but the order in which they appeared in the .htaccess file.
I read a WP forum post in which someone suggested moving the rewrites to the top of the file for performance reasons. I gave it a shot just to see what would happen and noticed that the URL for the articles was affected - not in a good way, but affected nonetheless. I got something like this:
www.site.com/wordpressindex.php?/2014/05/16/article-slug
There were some rewrite rules to rewrite the base and redirect to the index given a nonexistent directory or file, which was what was building the garbled URL above.
In case it happens to help anyone else, I began with a .htaccess file that looked like this:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
And ended up rearranging it to look like this, which now works to properly redirect all blog-related URLs to the www site:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{HTTP_HOST}/wordpress ^site\.com/wordpress [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
Try:
RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
RewriteRule (.*) http://www\.site\.com/wordpress/$1 [R=301,L]
And clean your browser history to make sure.
I also own a WordPress website and I was looking for www to non www redirect for my website : fasterthemes.com
The website is hosted in DigitalOcean and after struggling with several DAYS, I could figure out that all the solutions (.htaccess) codes available work fine if you've set the A record in your DNS settings properly. If it's not set then the redirection doesn't work !
So in my case,
I created one A record in my Digitalocean DNS like below :
i.stack.imgur.com/ie7f8.png
I added following code :
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.)$ http://%1/$1 [R=301,L]
And now as you can see if you browse http://www.fasterthemes.com , it redirects you to fasterthemes.com. Earlier it was throwing an error.
I hope this helps.

PHP Nuke to WordPress migration URL redirection

I have to migrate a medium-sized site based on PHP Nuke (less than 2000 posts) to a new WordPress installation. I have problems writing the redirection rules. I tried:
RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]*)
RewriteRule ^nuke/modules.php$ http://domain.com/%1? [R=301,L]
So
http://domain.com/nuke/modules.php?name=News&file=article&sid=1
should become
http://domain.com/1
It doesn’t work. I tried the .htaccess file in the “nuke”, “modules” and “News” folder with not luck. Any help would be very appreciated.
Here's the working code
RewriteEngine On
RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]*)
RewriteRule ^modules.php$ http://domain.com/%1? [R=301,L]
If you place the htaccess file in the "nuke" folder, you need to omit the nuke from the pattern:
RewriteCond %{QUERY_STRING} ^name=News&file=article&sid=([0-9]*)
RewriteRule ^modules.php$ http://domain.com/%1? [R=301,L]
And make sure you've turned on the rewrite engine:
RewriteEngine On

Resources