More threads by Wirenut

Can you post the redirection code you used?
Sure. Right now the only redirection code I have for this type of thing is what GoDaddy put in when they switched my site from http to https. It's what I posted earlier in the thread, this code:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]
RewriteRule ^(.*)$ https://mysite.com/$1 [L,R=301]
</IfModule>
 
Sometimes you have to play with the RewriteRule line a bit for different server configurations.

Comment out this line by inserting the character # at the beginning of the line:
Code:
# RewriteRule ^(.*)$ https://mysite.com/$1 [L,R=301]

Then try this right below that commented out line:
Code:
RewriteRule ^\$\/?(.*)$ "https\:\/\/www\.mysite\.com\/\$$1" [R=301,L]
 
I will try that when I get back to the office.

In the meantime I have a question just for my own curiosity. Is it good practice to have a redirect from mysite.com to www.mysite.com? Or is this just me trying to appease my OCD? :giggle:
 
Once you get your htaccess running correctly, that IS the redirect.

Do you have cPanel?
 
Yes, I have cPanel.

What I meant to ask is if it matters if someone could go to either www. or just mysite.com without the www.? Is it important to redirect to one or the other?
 
Technically, it doesn't matter which url the typical user lands on. But yes, you should redirect everything to your canonical url, that's one of the signals that tells Google what your canonical url is.
 
cPanel >> Domains >> Redirects
  • Set Type to permanent (301)
  • Set https?://(www.)? to your domain
  • Leave the box after / blanck
  • Redirects to https://yourdomain.com
  • Select Redirect with or without www
  • Check Wildcard redirect
 
cPanel >> Domains >> Redirects
  • Set Type to permanent (301)
  • Set https?://(www.)? to your domain
  • Leave the box after / blanck
  • Redirects to https://yourdomain.com
  • Select Redirect with or without www
  • Check Wildcard redirect
That didn't work. When typing in the domain without www. it still goes there, it doesn't get redirected to www.

Furthermore, and I know this might sound crazy, but when I entered that as you specified, it actually deleted an existing redirect. I remember there was an odd redirect at the very top of the Current Redirect list, and now it is gone. And now when typing http (without the s) of my website in it will take me to a non-secure version. So I lost that main redirect that GoDaddy added. I don't know why adding a redirect thru cPanel would remove an existing one.
 
So I checked the htaccess. It changed the redirect that GoDaddy added that I posted in the second post to this:
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>

So I pasted the original code back in htaccess and all is well.
 
OK. So it now redirects with or without the www?
 
When typing just the website in, it will forward from mydomain.com to www.mydomain.com.

but if I type in https://mydomain.com it will stay there (no www.) as I surf the site
 
Did you try what I suggested earlier?

Sometimes you have to play with the RewriteRule line a bit for different server configurations.

Comment out this line by inserting the character # at the beginning of the line:
Code:
# RewriteRule ^(.*)$ https://mysite.com/$1 [L,R=301]

Then try this right below that commented out line:
Code:
RewriteRule ^\$\/?(.*)$ "https\:\/\/www\.mysite\.com\/\$$1" [R=301,L]
 
I did mention out the line and add your line like you said. It's still doing the same thing.

The first post I had on this topic was a little off. As I clarified above, it only does it when typing https://mydomain.com which is an odd thing to do. I don't know if anyone or any spider would ever do that.

When typing mydomain.com (without the https in front of it) it goes to www.mydomain.com like it's supposed to.
 

Login / Register

Already a member?   LOG IN
Not a member yet?   REGISTER

Events

LocalU Webinar

  Promoted Posts

New advertising option: A review of your product or service posted by a Sterling Sky employee. This will also be shared on the Sterling Sky & LSF Twitter accounts, our Facebook group, LinkedIn, and both newsletters. More...
Top Bottom