SEO Urls with htaccess and SSL - .htaccess

I have an issue where the following rule works without SSL however when i change to https the rule doesn't work at all
RewriteEngine On
RewriteRule ^signins/?$ /login.php
Its driving me crazy please help :(

Look into your <VirtualHost> config for your https site it might be using a different DOCUMENT_ROOT.

Related

How to redirect all traffic via .htaccess to https

I have wasted endless hours trying to redirect all traffic (domain.com,www.domain.com, chat.domain.com) to https. I want to keep the domain name generic because there are other domain names parked on the site.
The best rules I could come up with so far, after lots of googling, trial and error, is this:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Unfortunately, these rules do NOT work for URLs belong to the subdomain.
Go through the following checklist:
The SSL certificate is valid.
The rule is defined somewhere all subdomains can actually visit 9and will have to visit).
If the rules are inside an htaccess file, the AllowOverride directive is set to All in server configuration.

Google has listed me as https://

Has anyone come across such an issue before? Where there site has been listed at https instead of http:
My homepage has been listed as https:// so when they visit it they get a security warning, i have never had and never mentioned ssl anywhere on my website at any point.
Does anyone have any ideas what this could be and how i can rectify it?
Is there any possible way i can redirect anyone that ever goes to https to http.
I have already tried putting in 301 redirects with no luck.
Thank you!
You can use this rule in root .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]

Removing www when using https protocol in htaccess

First I bought a multi-domains SSL certificate that doesn't allow wildcards (ex. *.mydomain.com).
When I want to connect to my website and if I go through https://mydomain.com it works fine. Now, if I go through https://www.mydomain.com I have a nice alert page from my browser saying I've got to add an exception, blahblahbla... So I understand I've got this alert because the SSL certificate doesn't manage www wildcard.
I decided to create a rule in htaccess in order to redirect user from https://www.mydomain.com to https://mydomain.com. But my browser seems not to understand this rule, and each time I go through https://www.mydomain.com I stay on https://www.mydomain.com.
Here is my rule :
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1 [L,R=301]
For information, I use Virtualmin to manage my domains.
Thanks!
Unfortunately .htaccess or mod_rewrite won't be of any help here in eliminating browser security warning.
Reason is that the SSL certificate negotiation happens well before mod_rewrite get a chance to kick in.
When you buy SSL cert I believe you get an option for cert being applicable for both www and non-www domains.

301 redirect rule in htaccess

What am i doing wrong? this rule isn't working
I want the xyz-banking(old) to xyzbanks(new)
RewriteRule ^category/xyz-banking/?$ http://www.domainname.com/category/xyzbanks/ [L,R=301]
When there are multiple categories goes to one new category...can i do this?
RewriteRule ^category/(chicos|chs|rl)/?$ http://www.domain.com/category/apparel/ [L,R=301]
Ofcourse that one is also not working.
Both rewrite rules seem to be correct and they should work.
Whenever you browse to: http://www.domain.com/category/chs/ you will be redirected to http://www.domain.com/category/apparel/ as requested, etc.
Maybe you have a problem somewhere else:
Is mod_rewrite enabled?
Make sure you have RewriteEngine On on your .htaccess or site configuration.
If using an .htaccess file, Make sure you have an AllowOverride directive that allows you to use RewriteRule there.
Try a simple redirect rule first!
Check your error and access logs to see if you can spot any error or warning message.
Take a look at the URL Rewriting Guide - Apache HTTP Server

http to https redirection using .htaccess not working

I want to redirect http://myip/admin to https://myip/admin. I am trying to use .htaccess to do this (want this only for the admin folder).
Contents of .htaccess placed in the relevant folder:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
(apache mod_rewrite is enabled). Both http://myip/admin and https://myip/admin are visible (but the redirection does not work). Server is Ubuntu.
I have tried few variations of the above rules from the internet but no luck :(
Any inputs would be appreciated.
regards,
JP
Solved it and learnt something new. The AllowOverride option in apache's main config file was not set correctly.
Also, if someone faces such issues 2 points:
1) apache reload may sometime not work as expected. Try restart
2) Clear browser cache and / or refresh page.

Resources