My sub folder is not working after modifying .htaccess - .htaccess

I have recently upgraded to SSL certificate and overwrites the .htaccess file with fallowing code
the code the code is look like this
RewriteEngine On
RewriteCond %{HTTP_HOST} parisakam\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://parisakam.com/$1 [R,L]
the website is a online shopping website, i cant access any sub folders.How can i short out this problem ?

Related

How To Redirect Whole site to another site except the Root Page

I want to redirect every url of my site except the root i.e., the home index.html
Basically I want everything after the / to redirect.
For example: If I visit website.com it should normally show the index.html page placed in the root. But if I goto website.com/someurl then it should redirect to website2.com/someurl
The site shouldn't redirect only for the root (home) page, and Should redirect for all other links.
Another 2 things I might add is:
The website2.com is https connection
I also want to use it in sub domain. i.e., at sub.website.com
Please help me with the relevant .htaccess code.
Thank You
Please try this and check
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.website.com [NC]
RewriteRule ^(.*)$ http://website2.com/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^(.*)\.website\.com$ [NC]
RewriteRule ^(.*)$ http://%1.website2.com/$1 [R=301,L]
The following code finally worked for me:
RewriteEngine on
RewriteBase /
RewriteRule ^.+$ https://newsite.com/$0 [R=301,L]

Domain redirection with folder separation. htaccess

After redirecting my client domain to my server i created rewrite rule in root folder .htaccess file to point domain to a subfolder1 (joomla website):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myclientdomain\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !/subfolder/
RewriteRule ^(.*)$ /subfolder1/$1 [L]
Everything worked fine but today i found out that i can access any other subfolder in my server by entering for example: myclientdomain.com/subfolder2 and what's worse google can index that and show it in search results.
If there is any way to redirect a domain in a way that I won't be able to access any other folder on my server?
I would really appreciate help as I searched throughout google for answer, my server tech support said that they don't really support these kind of problems (they only gave me a piece of code from above) and I don't really know anything about .htaccess rules and how it works.
Try this
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myclientdomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subfolder\/?(.*)?$
RewriteRule ^(.*)$ /subfolder1/$1 [L]
Change above rule to:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myclientdomain\.com$ [NC]
# if current URI is not starting with /subfolder/ then route to /subfolder/
RewriteRule ^((?!subfolder1/).*)$ subfolder1/$1 [L,NC]

Forcing just one HTML page to open via SSL using .htaccess

I want to force all clients to use SSL to access an HTML file on my website. It is snipprintslive.html in my root folder: www.stellamays.co.uk/sniprintslive.html.
I’ve tried:
RewriteEngine On
#https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^sniprintslive https://stellamays.co.uk/sniprintslive [R=301,L]
This works for the rest of the site but access to sniprintslive.html gives “file not found” error.
I tried putting the page in a subfolder (nightmare for relative links but hey ho) and putting .htaccess file in the same folder.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} printsfolder/sniprintslive.html
RewriteRule ^(.*)$ https://www.stellamays.co.uk/printsfolder/sniprintslive.html$1 [R,L]
Again I received the same error.
I don't understand this programming language but wondered if it’s the www or http: stuff which is upsetting it.
Note that my server will work with .htaccess as I successfully forced the whole site to open with HTTPS using similar code.
fixed it with this...I was a bit scared of the code cos I didn't get to put my website in???!
but it worked perflectly
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} /sniprintslive.html
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]

htaccess - Point domain and a sub domain to a folder

I have two folders on FTP root. site_v1 and site_v2. site_v2 has new version of website and site_v1 has older version. I wanted to point my domain to site_v2, the latest version. So I made an .htaccess on root as under.
RewriteCond %{HTTP_HOST} example.com
RewriteCond %{REQUEST_URI} !site_v2/
RewriteRule ^(.*)$ site_v2/$1 [L]
This works well. When I open http://example.com; site_v2 loads seamlessly.
Then, for site_v1, I created a sub domain http://old.example.com and pointed it to site_v1 folder; I get this error when I run http://old.example.com.
The requested URL /site_v1/site_v2/site_v1/index.html
was not found on this server.
I am clueless. It seems that http://old.example.com is still pointing to site_v2 because of .htaccess on root. What could be the solution so I can force old.example.com to load in site_v1?
Try changing your rules to:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/site_v[0-9]/
RewriteRule ^(.*)$ /site_v2/$1 [L]
RewriteCond %{HTTP_HOST} ^old\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/site_v[0-9]/
RewriteRule ^(.*)$ /site_v1/$1 [L]
This way, the host matching against the `%{HTTP_HOST} var won't overlap.

TYPO3 Force HTTPS in FE

I have two domains pointing to the same website, domain A and domain B. I want:
Domain A to be accessible via HTTP (works fine out of the box)
Domain B to redirect all requests to HTTPS. Basically if you type in http://domainb.com/somepage to redirect to http*s*://domainb.com/somepage. I would prefer to have this done via htaccess file.
I tried many solutions and I always get into redirection loop. Eg. I tried this:
RewriteCond %{SERVER_NAME} ^www\.domainb\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
....
rest of the standard typo3 htaccess commands.
My code was after typo3 be redirection part and before "Main URL rewriting" part in the htaccess file.
With code above I'm redirected to https but then "redirection loop" error is shown.
Any help is highly appreciated.
This works for me :)
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} domainb\.com$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
I include this code right after this line with RewriteEngine On.
Try this:
RewriteRule ^http://www\.domainb\.com/(.*) https://www\.domainb\.com/$1 [R=301,L]
The only solution that worked for me was the following one:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

Resources