wildcard ssl .htaccess file causes 500 error on laravel subdomain - wordpress

I have a wildcard ssl installed on my account (My host is Bluehost) and I followed the directions here from Bluehost's site to install the wildcard SSL. However, when I try and access the site at all it comes up with a 500 internal server error. I am using laravel framework right now for the subdomain, I don't know if that changes anything, but here is the .htaccess file for the main site (Which is a wordpress site):
# Custom subdomain .htaccess SSL + WordPress
RewriteCond %{HTTP_HOST} ^admin.mysite.com$
RewriteCond %{REQUEST_URI} !^/admin/public/
RewriteRule ^(.*)$ /admin/public/$1
RewriteCond %{HTTP_HOST} ^admin.mysite.com$
RewriteRule ^(/)?$ admin/public/index.php [L]
# End custom subdomain .htaccess
# BEGIN WordPress
AddHandler application/x-httpd-php70s .php
<IfModule mod_rewrite.c>
# Custom maindomain .htaccess WordPress
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# End custom maindomain .htaccess
</IfModule>
# END WordPress
And here is the .htaccess file for the subdomain (the one with laravel installed):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Keep in mind too, I know nothing about .htaccess or how it works, I just did what the webpage said to do.

I suggest you to try below code for simple redirection HTTP to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
This should work for your main domain and its sub-domain both. Now if you want to redirect Non-WWW domain to WWW then try below code;
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.domainname.com%{REQUEST_URI} [L,R=301]

Related

.htaccess wordpress - rewrite subdomains to main domain

I have a wordpress site with the wordpress files in a different folder (wpaw)
Wordpress url https://example.com/wapw
Site url https://example.com
I also have 3 or 4 subdomains, for example new.example.com
Currently the main domain and all the subdomains work correctly with the following RewriteRule
RewriteEngine On
RewriteRule %{REQUEST_URI} !^/wpaw/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wpaw/$1
RewriteRule ^(/)?$ /wpaw/index.php [L]
How can I modify the above so that http(s)://anysubdomain.example.com also redirects to https://example.com
Please write the below code in .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteEngine On
RewriteCond %{HTTP_HOST} ^anysubdomain\.example\.com [NC]
RewriteRule ^(.*) https:/.example.com/$1 [L,R=301]
</IfModule>
Thanks

Redirect 2 folders from https to http on WordPress

My WordPress hosted website is in https, but I want to remove https for two folders as I need to run http pages inside that pages using iframe. I have tried editing in .htacess file, but nothing worked.
I have tried using PHP code too, nothing worked.
Here is my .htacess file
<IfModule mod_rewrite.c><br>
RewriteEngine On<br>
RewriteCond %{HTTPS} off<br>
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]<br>
</IfModule><br>
SetEnv PHPRC /home/mysitename/public_html/php.ini<br>
# BEGIN WordPress<br>
<IfModule mod_rewrite.c><br>
RewriteEngine On<br>
RewriteBase /<br>
RewriteRule ^index\.php$ - [L]<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]<br><br>
</IfModule>
# END WordPress
# This entry meant for .htaccess file
RewriteEngine on
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} / [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L,NE]
RewriteRule (.*) /index.php [L]
# RewriteRule (.*) /folder/path [L]

Wordpress redirection loop error

I created a website few days back with a url http://abctest.com in wordpress. Now the website has been published to a domain http://www.bcdefg.com.
The server is same, I have not migrated the site, only the domain has been pointed to the same server. I have changed the wphome and wpsite url to respective domain.
What I want to achieve is to redirect all http://abctest.com or http://www.abctest.com requests to http://www.bcdefg.com.
I tried to use .htaccess redirection but that leads to Too many redirection error. Any solution ?
Below is my htaccess code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !bcdefg.com$ [NC]
RewriteRule ^(.*)$ http://www.bcdefg.com/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Error is on your rewriteCond : your host is www.bcdef.com and not bcdef.com (www is important)
try replacing this
RewriteCond %{HTTP_HOST} !bcdefg.com$ [NC]
by this :
RewriteCond %{HTTP_HOST} !www.bcdefg.com$ [NC]

Virtual subdomains using .htaccess

I am trying to create virtual subdomains using .htaccess and wordpress.
But it won't seem to work properly. Using wordpress I get urls like:
foo.eu/test-pagina/?lang=fr
I managed to rewrite this to what i want:
fr.foo.eu/test-pagina/
But when this url is rewritten the page returns an 500 internal server error.
I also made a wildcard for the subdomains in my dns configuration.
Do I have to make subfolders for each subdomain in my root ?
My current .htaccess code is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^\?]*)\?lang=([a-z]{2})&?([^\ ]*)
#RewriteRule ^ http://%2.hypnose.eu/%1?%3 [L,R]
RewriteCond %{QUERY_STRING} !(^|&)lang=
RewriteCond %{HTTP_HOST} ^([a-z]{2})\.hypnose\.eu$ [NC]
RewriteRule ^(.*)$ /$1?lang=%1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Can anyone tell me what did I do wrong?
Have you added "fr" as your subdomain in the domain's control panel?
Add this in your htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/test-pagina/%1/$1 [L,NC,QSA]

.htaccess vBulletin (with VBSEO) and wordpress issue

I have vBulletin installed at root with VBSEO installed also with this .htaccess at root:
ErrorDocument 404 /404..php
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine On
# DO 301 non www
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /
#RewriteCond %{HTTP_HOST} !^www\.domain\.com
#RewriteRule (.*) http://www.domain.com/$1 [L,R=301]
RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
#SECFILTERENGINE OFF
#SECFILTERSCANPOST OFF
and wordpress installed in a subfolder /blog/
Wordpress works fine until I try to use permalink settings such as "Post name". Wordpress add a .htaccess file in /blog/ with the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Wordpress then no longer is accessible and Firefox detects that the server is redirecting the request for this address in a way that will never complete.
Any advice on fixed this issue woulde be greatly appreciated.

Resources