I am trying to follow up on an issue we are having with a site, related to SSL, whereby some of the CSS and JS links are given a port 443 (:443) in their URL by wordpress.
I have found the following lines in the .htaccess files - wonder if it's because of that?
Can someone pls explain to me what this is doing?
Thanks in advance
RewriteCond %{HTTPS} on
RewriteRule .* - [E=WPR_SSL:-https]
RewriteCond %{SERVER_PORT} ^443$
RewriteRule .* - [E=WPR_SSL:-https]
Related
I want to redirect https://www.siteone.com/testpage-es.html to http://newsite.com
When I'm testing my code in a htaccess tester (https://htaccess.madewithlove.be/) it shows the following result.
"The new URL is http://newsite.com:443/"
My code is snippet as follows.
RewriteCond %{HTTP_HOST} ^www.siteone.com$ [NC]
RewriteRule ^testpage-es.html$ http://newsite.com [L,R=301,NC]
Could anyone please help me to get rid of ":443/" part?
Add port to your rewrite
RewriteCond %{HTTP_HOST} ^(www\.)?siteone\.com$ [NC]
RewriteRule ^testpage-es\.html$ http://newsite.com:443 [L,R=301,NC]
But port 443 is default for SSL/HTTPS so rule should look (with https:// not port number)
RewriteCond %{HTTP_HOST} ^(www\.)?siteone\.com$ [NC]
RewriteRule ^testpage-es\.html$ https://newsite.com [L,R=301,NC]
Finally, I was able to find the answer. This is only a problem related to the htaccess checker with https websites. The code I mentioned above worked properly in the live environment. (I was hesitant to check it with the live web site without being 100% sure. However, it works well in the live environment.)
I was trying to get an entire directory/section of my website to automatically re-direct to https (secure) using the .htaccess file, so I found a solution on here. It turns out it re-directs my ENTIRE site to HTTPS except for the homepage. I'd like it to only re-direct the /php/ folder and anything inside it.
Thanks in advance for any help!
Here is my code in .htaccess:
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} php
RewriteRule ^(.*)$ https://beanstalkwebsolutions.com/$1 [R,L]
You can use this rule as your very first rule:
RewriteCond %{HTTPS} off
RewriteRule ^php(/|$) https://beanstalkwebsolutions.com%{REQUEST_URI} [NC,R,L]
I got wordpress installed in /WP. So i browsed the web to find an example of a htaccess that can redirect the user from domain.se to domain.se/wp. So if anyone just types in the domain name then they will be redirected to the /wp folder.
This was the one i found and it works.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ http://domain.se/wp/$1 [R,L]
Question is, is it ok like this or is this a bad solution?
I think your code should be the following :
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/wp
RewriteRule ^(.*)$ http://domain.se/wp/$1 [R,L]
I'm trying to disable HTTPS on domain names that do not have SSL certificates, I am using this code but it doesn't seem to be doing anything. My website is running Wordpress and the wordpress htaccess is working fine, but the HTTPS bit seems to be nothing. This is the code I am using with wordpress' htaccess:
I'm now using the code from the 'possible duplicate' above and it's not working for me:
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
Any help would be greatly appreciated!
You're using capture group # 1 i.e. $1 without using capturing a group using square brackets.
Change your code to this:
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
There was a misconfiguration on the server that was preventing the rewrite rules from functioning. I contacted Host Gator and they confirmed they had installed an SSL certificate improperly which was causing the problems.
Thank you all for your help; I greatly appreciate it.
Below is the email from HostGator for archival purposes of this question.
Hello,
Thank you for contacting Host Gator, I will be more than happy to
assist you with this.
We apologize for any inconvenience this has caused.
It appears your SSL was installed incorrectly, we have updated your IP
for the SSL and you should have no other issue with it.
If you have any other questions please let us know.
Regards,
Elizabeth R.
HostGator.com LLC
**Always use https for secure connections
Replace 'www.example.com' with your domain name
(as it appears on your SSL certificate**)
Put this code inside .htaccess
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Reference
I have found similar questions, however no-matter what I try I am unable to get htaccess to do what I need it to. What I'd like is to direct visitors to an SSL connection when visiting one (or more) virtual subdirectories and then reverse this when they leave these selected subdirectories.
My rules look like this:
Options +FollowSymlinks
RewriteEngine on
#switch on SSL in /directory/ only
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/directory/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#switch off SSL in other folders
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/directory/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteRule ^([^/\.]+)/?$ /index.php?var1=$1 [NC,L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+).html /index.php?var1=$1&var2=$2 [NC,L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?var1=$1&var2=$2 [NC,L,QSA]
It seems that switching on SSL and switching off SSL conflict and when I try to access any page via https://www.domain.com/foo/ I am correctly redirected to http://www.domain.com/foo/.
However, when trying to access http://www.domain.com/directory/ (which should be SSL) I am redirected to http://www.domain.com/index.php?var1=directory and not https://www.domain.com/directory/.
I would really really appreciate a bit of guidance over where I'm going wrong. I've trawled through stackoverflow and the web for hours and hours looking for an answer but I'm just going round in circles and can't see the wood from the trees.
Thank you for any guidance/help you can offer.