Htaccess rewrite rule (very specific)
-
Hello,
Awhile back my company changed from http: to https: sitewide (before i started working here). We use a very standard rewrite rule that looks like this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://opiates.com/$1 [R,L]However, with this rule in place, some http: urls are being redirected with a 302 status code. My question is, can I safely change the above code to look like this:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://opiates.com/$1 [R=301,L]to ensure that every redirected is returned with a 301 status code. The only change is in the [R,L] section. Thanks to whomever can help with this. I'm pretty sure its safe but I dont want the site to go down, even for a second, so figured I would ask first.
-
Just one more note:
You have a Double Redirect and you should write your Rewrite rules to avoid this double redirect as each redirect will cause some loss of page juice.
Checked link: http://www.opiates.com/
Type of redirect: 301 Moved Permanently
Redirected to: http://opiates.com/
2.
Checked link: http://opiates.com/
Type of redirect: 302 Found
Redirected to: https://opiates.com/
-
This should work out just fine. If you want to confirm that it is effective, you can backup the old htaccess, upload the new one, go to one of the previously 302'd pages and see if it 301s now. You can check this using the network tab in Chrome's developer tools.
-
That's perfectly fine.
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
-
International SEO and Indexing in Country Specific Search Engines
Hey everyone! My company has recently migrated to a new domain (www.napoleon.com) which includes migrating many TLD separate domains to the new. We have structured the website to have multi-language and regions, including regional content, product offerings etc. Our structure is as follows just to give an example. napoleon.com/en/ca/
Intermediate & Advanced SEO | | Napoleon.com
napoleon.com/fr/ca/
napoleon.com/en/us/
napoleon.com/de/de Currently, specifically the homepage version of the USA website is indexing into Canadian Search Engines, and I can't figure out why. It has been roughly 6 weeks since launch. Any thoughts on this? Thank you Dustin0 -
Set Robots.txt file to crawl my website at specific times
Our website provider has stated that they can only 'lift' their block on our website in order for it to be crawled as specific times. Is there any way to amend a robots.txt to ensure that it crawls our website at a specific time of day/night in order to coincide with the block being lifted? Many Thanks, Charlene
Intermediate & Advanced SEO | | CharleneKennedy120 -
Do industry specific domains help SEO?
Hi everyone, I've looked for an answer to this but I can't find one. Hopefully someone can help! I have a new client that is a builder. They currently have a .co.uk domain (e.g. businessname.co.uk) Would it help them if the website was businessname_.builders_ instead? Thanks, Alex
Intermediate & Advanced SEO | | WebsiteAbility0 -
Why does Moz recommend subdomains for language-specific websites?
In Moz's domain recommendations, they recommend subdirectories instead of subdomains (which agrees with my experience), but make an exception for language-specific websites: Since search engines keep different metrics for domains than they do subdomains, it is recommended that webmasters place link-worthy content like blogs in subfolders rather than subdomains. (i.e. www.example.com/blog/ rather than blog.example.com) The notable exceptions to this are language-specific websites. (i.e., en.example.com for the English version of the website). Why are language-specific websites excepted from this advice? Why are subdomains preferable for language-specific websites? Google's advice says subdirectories are fine for language-specific websites, and GSC allows geographic settings at the subdirectory level (which may or may not even be needed, since language-specific sites may not be geographic-specific), so I'm unsure why Moz would suggest using subdirectories in this case.
Intermediate & Advanced SEO | | AdamThompson0 -
Why is Google rewriting titles with the brandname @ the front followed with a conon " : " i.e. > Brandname: the rest of the title
Example: https://www.google.nl/search?q=providercheck.nl&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#bav=on.2,or.r_cp.r_qf.&ei=9xUCUuH6DYPePYHSgKgJ&fp=96e0b845c2047734&q=www.providercheck.nl&rls=org.mozilla:en-US:official&sa=X&spell=1&ved=0CC4QBSgA Look @ the first result: www.providercheck.nl
Intermediate & Advanced SEO | | Zanox0 -
Redirect 1 specific link from a referrer, wise move?
This might be a bit of a complex question as it has many implications and I’d really appreciate some expert advice. I have a client who has one specific .gov link which is absolutely amazing. It doesn’t have any anchor text and goes straight to the homepage. However it drives quite a lot of revenue! It’s lovely as SEO’s to think of links actually driving revenue rather than assisting rankings of course. Over the last 30 days this single govt. link has driven: 418 clicks, 61 conversions, $7,500 revenue Not bad I hear you say! J I really want to extract maximum value from this and I’ sure it would perform far better if it went to a really tightly focused landing page rather than the homepage. It really is hyper-targeted buyer traffic (as the stats show) but could perform even better in my opinion. I can’t change the link, that’s not possible unfortunately. However I can do some server side stuff to redirect traffic from just this link to a desired new page. However, what are the SEO implications of this in the opinion of some of the experts here? Obviously the link itself is valuable from an SEO perspective and I don’t want to lose that. I’m not sure how Google would treat the link if this were to be done. Also I really want to A/B test the homepage versus a landing page to ensure that it really does give an improvement. I’m not even sure how to achieve that given the difficulty in this situation. Any advice would really be useful! Thanks J
Intermediate & Advanced SEO | | HarveyP0 -
How is it possible to 301 specific pages to a new domain?
The old site is small, only 100 pages or so, and about 10 of them are particularly useful. I would like to 301 those 10 pages to 10 similar pages on the new site, and also 301 the other 90 pages to the new site... the new site's home page, I suppose. Does it make sense to do this and if so how? I think if I simply 301 the whole of the old domain to the new one, the juice will be shared among the new site's page equally which is not what I want. I know where the htaccess file is and I can 301 a page within a domain but I'm at a loss with this. Thanks for any help. EDIT: I'm hoping for something like this: old.com/page_1 >> new.com/page_A old.com/page_2 >> new.com/page_B ... and 8 more of those And then the other 90 pages: old.com/Remaining pages >> new.com/index
Intermediate & Advanced SEO | | Brocberry0 -
How to fix a canonical problem with no htaccess?
Basically I need to find a way to fix my canonical problem. The www and no-www version of my site each show up. This creates duplicate content. I have no htaccess with yahoo. How else can I fix this problem? Does anyone have a sample code I could use?
Intermediate & Advanced SEO | | bronxpad0