Redirect Issue in .htaccess
-
Hi, I'm stumped on this, so I'm hoping someone can help. I have a Wordpress site that I migrated to https about a year ago. Shortly after I added some code to my .htaccess file. My intention was to force https and www to all pages. I did see a moderate decline in rankings around the same time, so I feel the code may be wrong. Also, when I run the domain through Open Site Explorer all of the internal links are showing 301 redirects. The code I'm using is below. Thank you in advance for your help!
Redirect HTTP to HTTPS
RewriteEngine On
ensure www.
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]ensure https
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]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
USER IP BANNING
<limit get="" post="">order allow,deny
deny from 213.238.175.29
deny from 66.249.69.54
allow from all</limit>#Enable gzip compression
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript#Setting heading expires
<ifmodule mod_expires.c="">ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/x-ico "access plus 1 year"
ExpiresByType image/jpg "access plus 14 days"
ExpiresByType image/jpeg "access plus 14 days"
ExpiresByType image/gif "access plus 14 days"
ExpiresByType image/png "access plus 14 days"
ExpiresByType text/css "access plus 14 days"</ifmodule> -
The issue of the internal links of your site going through 301-redirects isn't being caused by the htaccess file, John - in fact that file is partially saving you from the bigger issue.
The problem is that your WordPress migration to HTTPS was incomplete.
After the migration, you missed the step of going through the WP database and changing all the static URLs to the HTTPS versions as well. This can be done using a mySQL query through phpMyAdmin, but the easiest way is to use the Better Search Replace plugin. (You need to be sure you're correctly handling serialised data, which the plugin does automatically.)
In addition, you're going to want to insure that you've updated the WordPress Address URL and the Site URL in Settings > General to the HTTPS versions of the URLs.
The final check will then be to make certain all the static assets loaded by the site (and any referenced from 3rd parties) are also being loaded over HTTPS as well. Watch especially for 3rd party form codes like newsletter subscription forms, social media widgets, and other widgets in sidebars as these aren't caught by the rewrite plugin I mentioned earlier. This step is essential to insure you don't have "mixed content" on the pages which cause you to get a non-secure warning from the browser.
You may have used a "Switch to HTTPS" plugin for this process initially, but the majority of those don't accomplish their task in the most SEO-effective way. Using the method outlines above will both make the search engines happier,and will make for faster webpage performance as well.
Let me know if you have further questions.
Paul
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
301 Question - issue
A while back we had a 'bleed' on one of our sites, which basically meant one of our sites started to leak across pages to another and that site started to rank for the same pages and now we have hundreds of pages ranking for urls that do not exists. It's hard to explain, bare with me. If you were to click on the cached view in Google for the ranked page it would show you the main site, but if you were to click it as usual, then you would be taken to the site but a 404 would show as the intended page was not for that site. We believe we fixed the 'bleed' and have setup 301s for all the affected pages to go to the home page for the site it affected. But these pages have not been removed from Google, which we thought a 301 would do. So we still have hundreds of pages being ranked but are redirected to the home page. Why hasn't these pages been removed?
Intermediate & Advanced SEO | | JH_OffLimits0 -
Weird Indexing Issues with the Pages and Rankings
When I found the my page was non-existent on the search results page, I requested Google to index my page via the Search Console. And then just a few minutes after I did that, that page rose to top 3 ranking on the search page (with the same keyword and browser search). It happens to most of the pages on my website. Maybe a week later the rankings sank again, and I had to do the process again to make my pages to the top. Any reasons to explain this phenomenon, and how I can fix this issue? Thank you in advance.
Intermediate & Advanced SEO | | mrmrsteven0 -
Redirect 301 still works?
Hi, yesterday a friend said that 301 redirects does not transfer your page rank or domain autorithy anymore. I could'nt find anything in internet saying it, but I decided to ask you guys, since I think you are very reliable. so, 301 redirects wroks for transfer page rank, and i can create better domains and transfer everything, or this strategy is gone forever now?
Intermediate & Advanced SEO | | chablau0 -
Hundreds of 301 Redirects. Remove Pages or Not?
Hi Mozers, I have a website that has literally got hundreds of 301 redirects. I had a close look at these URLs and only some of them have backlinks to it and remaining all of them are not indexing in Google and has got not backlinks at all. Based on what I have noticed experts mentioning, loads of 301 redirects can potentially slow down the site speed. In a case like the website I have, should I completely take off the pages from website to reduce the number of 301 redirects or should I leave 301 redirects? There is no traffic or backlinks coming from these URLs. Malika
Intermediate & Advanced SEO | | Malika10 -
Redirect ot new domain
Hello, Can someone give me advice on this specific situation: For now we have a website www.website.com/ Because of some specific business situation we want to move to .ca version but also we want to keep website.com - for U.S customers. Here's how I imagined to do this: 301 Redirect from www.website.com to website.ca. Because at this time website.com redirects to www.website.com I would remove the redirect and just keep it like website.com (so this will be new domain). Is this is the right solution? Regards, Nenad
Intermediate & Advanced SEO | | Uniline0 -
WMT Showing Duplicate Meta Description Issues Altough Posts Were Redirected
Dear Moz Community, Some time ago we've change the structure of our website and we've redirected the old URL's to the new ones. About 2,000 posts were redirected at that time. While checking Webmaster Tools a few days ago I've discovered that about 500 duplicate meta-description issues appear in the "HTML Improvements" area. To my surprise, altough the old posts were redirected to the new path, WMT sees the description of the old posts similar with the one of the new post. Moreover, after changing the structure all meta-descriptions were modified and they weren't the same used before the restructure. For example I've redirected /blog/taxi-transfer-from-merton-sw19-to-london-city-airport/ to /destinations/greater-london/merton-sw19/taxi-transfer-to-london-city-airport-from-merton/ Now they are shown as having duplicate content. I've checked the redirects and they are working. I get the same error from the redirected pages for about 150 titles. Did anyone else get this errors or can you please offer me some suggestions about how I can fix this? Thank you in advance! Tiberiu
Intermediate & Advanced SEO | | Tiberiu0 -
Iframe redirect bad for SEO?
Hi, I have a website (http://www.blowingminds.de) wich I put a spreadshirt shop into via iframe. The thing is I am not sure on how the iframe effects my SEO? Can I just optimise the main domain for search? Well I want the spreadshirt shop to be found under the domain name (www.blowingminds.de) but the only real way to do it is by implementing an iframe because each spreadshirt shop has its own subdomain eg.: blowingminds.spreadshirt.de but the only real way to do it is via iframe, as they do not offer a complete domain redirect. (Or have I overseen some other way?) I hope you guys can help me on this one 🙂 Thanks in advance. Malte
Intermediate & Advanced SEO | | wellbo1 -
Htaccess funny characters
Hi Panda update,tickled, slapped and then punched us. I'm now weeding through crawl errors, one of them is http://www.flasharcadegamessite.com/26226-paper-airplane-flight.html">paper airplane flight I tried 301 this to it's proper page using Redirect 301 /26226-paper-airplane-flight.html">paper airplane flight http://www.flasharcadegamessite.com/26226-paper-airplane-flight.html but the server starts spitting out 500 errors. How does one add that rule into htaccess ? thanks
Intermediate & Advanced SEO | | Flapjack0