Its a godaddy root structure where we have to keep all files in the root directory to access the url as www.example.com, and any other domain has to be in the root directory of the primary domain with which the payment is done, pretty crappy structure from go daddy.
To avoid the clutter I made the one more folder inside root as /example/.. and pushed all the files form root to the mentioned folder,
earlier it was working fine, I had purchased ssl certificate but after the certificate expires, it was not opening the domain so I have made the rewritecond %{HTTPS} !off form rewritecond %{HTTPS} !on and now the redirection is not at all working,
I am really bad at .htaccess, so looking for best advice.
rewriteengine on
rewritecond %{HTTPS} !off
rewritecond %{HTTP_HOST} ^www.example.com$ [OR]
rewritecond %{HTTP_HOST} ^example.com$
rewriterule ^$ "http\:\/\/example\.com\/index\.php" [R=301,L] #51w512ed4b49c
rewriterule ^$ "http\:\/\/example\.com" [R=301,L] #51w512ed4b49c
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewritecond %{REQUEST_FILENAME} !-l
rewriterule ^(.*)$ /example/$1 [QSA]
rewritecond %{HTTPS} !off
rewritecond %{HTTP_HOST} ^(www.)?example.com$
rewriterule ^(/)?$ index.php [QSA,L]
I want the redirection from www.example.com to example.com
and url should look as example.com/index.php or example.com not as example.com/example/index.php or example.com/example/
Now I don't want the SSL and how to update the .htaccess
Why is internal server error is coming just for the example folder and not for any other folder.
Folder Structure in godaddy panel:
Related
So I'm having this website which is stored inside public_html/www/. Some other domains are stored in -for example- public_html/test/. In public_html I have a .htaccess file with a LOT of redirects in it, which all apply to this website inside /www/ folder. Inside the /www/ folder I have another .htaccess (I don't really know why, my colleague did this and he left me with this without information). Since I have no idea how .htaccess exactly works, I have no idea what to do and in which file.
What I need to do is to redirect domain.nl to https://www.domain.nl (some folders should be excluded, like you can see in the code below - emailtemplates, paymentupdate, autocode, nieuwsbrieven, etc.) But domain.nl is stored inside public_html/www/ folder, so it also needs a redirect to the subfolder (which should not be visible in web browser).
At this moment, in the root .htaccess file is the following:
# Use HTTPS
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.nl [NC]
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/emailtemplates
RewriteCond %{REQUEST_URI} !^/paymentupdate_ideal
RewriteCond %{REQUEST_URI} !^/autocode
RewriteCond %{REQUEST_URI} !^/nieuwsbrieven
RewriteCond %{REQUEST_URI} !^/bevestig-aanmelding-nieuwsbrief
RewriteCond %{REQUEST_URI} !^/bevestig-afspraak
RewriteCond %{REQUEST_URI} !^/images/personal
RewriteCond %{REQUEST_URI} !^/uploadify
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Link to subfolder
# RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
RewriteCond %{REQUEST_URI} !^/www/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /www/$1
RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
RewriteRule ^(/)?$ www/index.php?page=home [L]
# Non-www to www
#activate rewrite engine
#RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.nl
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
Probably half of this code isn't even necessary, but I have absolutely no clue. The other .htaccess file, within the subfolder /www/, has the following text which I don't really understand (it contains more, but nothing relevant):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.domain.nl/$1/ [L,R=301]
I'm sorry if I sound stupid. I've tried many things copied from internet, but unfortunately everything has its concequences, which results in other problems with our website (links that don't work anymore, such as). I think the reason it doesn't work all the time, is because it's stored in the subfolder and I don't know how to combine all those lines in one like it would work.
Can anybody help me explain how to fix this and what is going wrong at this moment? Because the website is now not redirecting to www. It's just redirecting to https which gives me a security error at this moment (because the SSL is stored on www.). SUPER thanks in advance!
My problem was wrong order of the checks. First, I redirected to https://, but when I did not use www., it did not redirect to https://www OR it redirected to https://www.www. I fixed my problem by re-ordering my rules, like below:
# Non-www to www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Permanent redirect to https://
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/excluded_folder1/
RewriteCond %{REQUEST_URI} !^/excluded_folder2/
RewriteCond %{REQUEST_URI} !^/excluded_folder3/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Use subfolder for domain
RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
RewriteCond %{REQUEST_URI} !^/www/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /www/$1
RewriteCond %{HTTP_HOST} ^(www.)?www.domain.nl$
RewriteRule ^(/)?$ www/index.php?page=home [L]
I don't know much about the .htaccess file and need some assistance please. I have a few websites hosted one one CPanel account. I didn't want to have my "main" site stored directly in the public_html folder, so I moved it into a subfolder and then found this .htaccess configuration that allows me to load my main site from that subdirectory. So that is working.
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on
# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/example_directory/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /example.com/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example.com/index.html
So as I said, the above .htaccess will allow me to store my site files in a different folder rather than right at the root. But now I'm trying to force a redirect for this site over https as well. I found this site here:
Force Website to Use SSL
But, since I really don't understand the .htaccess file I'm having trouble integrating these two features together. Any help on this would be greatly appreciated. Thanks.
I'm pretty certain I figured this out myself. I just simply had to add this to the end of my .htaccess file:
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
and it works like a charm. Full .htaccess file looks like this, which changes the folder directory for the site to use and then forces it over https.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/example_directory/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ example.com/index.html
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}
I have added a subdomain: support.mysite.com
The support directory is in the root directory. Now, whenever I try to access the subdomain, I I am redirected to the index.php file of the main domain.
For example, I try to access support.mysite.com/index.php and ending up at mysite.com/index.php
I guess it has something to do with the htaccess file for the main domain, which is:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
RewriteRule ^(.)$ http://%1/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
There is no htaccess file for the subdomain yet.
Any help would be appreciated!
I have a site1.com as my primary site. I created two folders in the root directory "site1" & "site2". I used Htaccess to redirect site1.com's traffic to folder "site1". Site2 works too as site2.com using directory "site2".
Now, the issue is because site1 is primary, I'm able to visit site2 via site.com/site2 . What rewrite can I use to ignore site.com/site2, or show a 404 when site1.com/site2 is visited and still allow for site2.com to work?
Here is my htaccess file.
RewriteEngine on
Options -MultiViews
RewriteCond %{HTTP_HOST} ^(www.)?site1.com$
RewriteCond %{REQUEST_URI} !^/site1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site1/$1
RewriteCond %{HTTP_HOST} ^(www.)?site1.com$
RewriteRule ^(/)?$ site1/index.php [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
My folder hierarchy is
-root
.htaccess
-site1 folder
- index.php
-site2 folder
- index.php
Due to godaddy's primary domain setup, even though when i visit site.com it loads info from site1 folder, if i visit site1.com/site2 it will load site 2
I went in a different direction for a similar problem on Godaddy.
Rather than looking for just hits from site1.com and redirect them, I sent any requests hitting the site2 subfolder / subdomain to site2.com with this:
RewriteCond %{HTTP_HOST} !^site2\.com$ [NC]
RewriteRule ^(.*)$ http://site2.com/$1 [R=301,L]
Now any requests that worm their way into that site1.com/site2 subfolder get 301'd to the appropriate page on site2.
I don't consider myself an expert by a longshot and would welcome critiques from those with more experience.
Untested code: I believe you can do the following
RewriteCond %{HTTP_HOST} ^(www.)?site1.com$
RewriteRule ^site2/(.*)$ http://site1.com/$1 [R=301]
This will (or should) redirect the client from http://site1.com/site2/my/awesome/page.php to http://site2.com/my/awesome/page.php.
I've created a subdomain called mobile for my website throuch cPanel. I redirect mobile devices to that subdomain, but there is javascript that lives there that makes AJAX calls to the actual domain. I have structured these calls to go to website.com/mobile/.... However, these aren't going through, and I suspect that it's because it is looking for ... in my /mobile, but the request is supposed to be rewritten in .htaccess to website.com/index.php?params=mobile/....
Here's the .htaccess:
# redirect phones/tablets to mobile site
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteCond %{REQUEST_URI} !^/mobile [NC]
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L,R=302]
# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# website.com/home => website.com/index.php?params=home
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]
This works on my local machine but not on the live server. I have created a sudomain locally via
<VirtualHost *:80>
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs/website/mobile"
ServerName mobile.website.local
</VirtualHost>
and it works perfectly: when I go to mobile.website.local or website.local/mobile, I get the mobile site, and when I go to website.local/mobile/users/login I get the correct JSON output for the AJAX request.
How can I keep my mobile subdomain alive in /mobile/ but have requests to website.com/mobile/... be forwarded with the last rewrite rule?
Thanks!
Just add the specific redirect for your /mobile, forcing to ignore the file or directory statement:
RewriteCond %{REQUEST_URI} ^/mobile [NC]
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]
# redirect phones/tablets to mobile site
RewriteCond %{HTTP_HOST} !mobile\.website\.com [NC]
RewriteCond %{REQUEST_URI} !^/mobile [NC]
RewriteCond %{QUERY_STRING} !^params=mobile(.*)$
RewriteRule ^(.*)$ http://www.mobile.website.com/$1 [L]
# not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# website.com/home => website.com/index.php?params=home
RewriteRule ^(.+)(\?.+)?$ index.php?params=$1 [L,QSA]
Anything let me know and I'll see if I can help :)