Rooturaj's Blog

The words of a Techie who loved Nature.

After cracking my heading for whole 3 hours I finally got to get the right htaccess code to direct the payment folder for a clients site to SSL secure platform – yes https connections.

Now I want to share the codes with you so that you don’t waste time and energy on that and help cutting out on green house emissions. lolz

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L]

If you want to redirect some particular folder to https version like

http://yoursite.com/securefolder/  to https://yoursite.com/securefolder/ then use this code on you htaccess file.


RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} securefolder
RewriteRule ^(.*)$ https://yoursite.com/$1 [R,L]

You can use the above code in the root htaccess file of your sites without any problem.

In case you want a different htaccess file in some particular folder then you should consider this alternative . Replace the last line of above code by this line.

RewriteRule ^(.*)$ https://yoursite.com/securefolder/$1 [R,L]

I will update more about this when I face problems regarding SSL redirections using htaccess. Till then if you have some problem implementing SSL redirections then do comment below.

Check if htaccess is enabled | Test if htaccess is working

Posted by rooturaj On December - 2 - 2010

I see newbie programmers cracking up on htaccess issues. Normally it is a simple process where you can get beautiful stuff working in about 5 minutes time.

Most of us find the required code by googling up our requirements. Its initially tough to master the htaccess coding. But when we put then to action on our own servers. It does not work. I have seen my own programmers spending days together trying to find out why the hell is .htaccess file is not working.

First you should know how to create a .htaccess file.  I suppose you know already. If not follow the link.

Ok now open you .htaccess file in a text editor and add this simple code to the file.

redirect 301 /filename.html http://rooturaj.com

Now there should be a file exactly called filename.html or create any file like test.html and replace the same int he code above. If your htaccess is working then you should be redirected to my site  http://rooturaj.com when you click on your link to http://yourdomainname.com/filename.html or enter it directly in the browser.

If it doesnot then your htaccess is not up. Contact your hosting provider and kick his ass till he get it up and working for you. I sincerely hope this post helped you in what you are looking for. Do share this or link to this page so that other may use it too.

SEO Canonicalization using htaccess

Posted by rooturaj On August - 14 - 2010

Hola webmaster… since you are here I assume you are looking for a solutions to redirect duplicate looking and sounding pages on your website to a global format. In the next 3 minutes you are going to do exactly that. Read on…

By the way did you know search engines see www.domain.com , domain.com and domain.com/index.php as three separate pages. So when the search engine arrives on the site it get confused.

SE Bot: What the hell? Which one is the right URL? Ok let me pick one which ever i think is good.

What you should do? You need to 301 redirect all the versions to one global version.

Ok enough Rambling Mr Pattanaik, tell me how to do it.

Well yeah. I use the htaccess method in apache servers. Here is how to do it for your website using htaccess.
Step 1: Create an HTACCESS file. Open notepad save the file as .htaccess …thats it.
Step 2: Add this code to the file in editor.

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com/$1 [R=301,L]

Step 3: Thats all. Upload the file to your root directory of the domain. Dont worry its not a virus or spam bot I am asking you to upload.

Now Share this post if you find it helpful.

VIDEO

TAG CLOUD

Sponsors