All posts by techworkshop

Redirecting HTTP to HTTPS Using .htaccess File

Chrome and Firefox have started showing insecure warnings to the visitors on websites without SSL certificates. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. For SSL-encryption, buy SSL certificates and install them to your websites.

But, installing SSL certificates will not show secure, you should also redirect all your HTTP traffic to HTTPS. In order to force your web traffic to use HTTPS, edit the codes in the .htaccess file. Before we move onto redirecting HTTP to HTTPS, here’s how you can edit .htaccess file. If you already know skip to Redirection steps.

Editing .htaccess File

There are instructions/directives in the .htaccess file that tell the server how to act in certain scenarios and directly affects how your website functions. Common directives in .htaccess file:

  • Redirects
  • Rewriting URLs

Ways to edit an .htaccess file:

  1. Edit the file on your computer and upload it to the server using FTP.
  2. Use “Edit” mode in FTP program that allows you to edit a file remotely.
  3. Use a text editor and SSH to edit the file.
  4. Use the File Manager in cPanel to edit the file.

Editing .htaccess in cPanel File Manager

Note: Backup your website in case something goes wrong.

  1. Login to cPanel
  2. Files > File Manager > Document Root for:
  3. Now select the domain name you want to access
  4. Check “Show Hidden Files (dotfiles)”
  5. Click “Go”
  6. After a new tab or window opens, look for the .htaccess file.
  7. Right click on the .htaccess file and click on “Code Edit” on the menu.
  8. A dialogue box may pop up asking about encoding. Click “Edit” button to continue.
  9. Edit the file
  10. “Save Changes” when done.
  11. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  12. Once you are done, click “Close” to close the window.

Redirecting HTTP to HTTPS

1. Redirect All Web Traffic

If you have existing code in your .htaccess, add the following:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$$1 [R,L]

2. Redirect Only a Specific Domain

For redirecting a specific domain to use HTTPS, add the following:

RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain\.com [NC]RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$$1 [R,L]

3. Redirect Only a Specific Folder

Redirecting to HTTPS on a specific folder, add the following:

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} folder RewriteRule ^(.*)$$1 [R,L]

Note: Replace “yourdomain” with your actual domain name wherever required. Also, in case of the folder, replace /folder with the actual folder name.

Think it was useful? Share this article to help them come on HTTPS

Jio GigaFiber Could Soon Reach Your Home As Reliance Industries Plans to Acquire Hathway Broadband

Reliance Industries wants to speed up the launch of Jio GigaFiber. In a bid to do that the company has initiated talks with Hathway. Hathway Cable and Datacom is India’s largest cable operator. RIL plans to buy the company so that Jio GigaFiber can reach the people sooner. They are doing everything to bring forward the commercial launch of their high-speed broadband services.

Hathway Cable and Datacom Ltd

Hathway is a cable company that operates multiple systems. In other words, it signs carriage and content agreements with broadcasters. It then provides its services to the local cable operators. The company’s average broadband business revenue (ARPU) per user in the June quarter was approximately Rs.710 per month.

Moreover, Hathway has more than 8,00,000 broadband and around 11 million digital TV users. The company’s promoter Raheja Group holds 43.48% shares of Hathway.

At the end of FY 2017-18, Hathway had a debt of around Rs.1,617 crore. The company is looking at ways to deleverage the balance sheet in the next couple of years by Rs.500 crores. Since July this year, Hathway’s promoters have planned to infuse Rs.350 crore in the company spread over the next 18 months. The capital infusion will take place in the form of long-term unsecured loans and equity.

Rajan Gupta, MD, Hathway, disclosed that the company received Rs.100 crore in July and another Rs.100 crore by August end. The balance Rs.150 crore would be received by them by March 2020. Besides this, in the next few months, the company will be earning Rs.150 crores from its operations.

RIL’s Acquisition of Hathway Broadband

Both Hathway and RIL have refused to comment on the development but insider sources confirm the news. According to them the talk between the two is still in its initial stages and all talks about the deal are still on an exploratory basis. They also revealed that even though it is not yet clear whether the negotiations will turn positive, RIL is pursuing this contract quite aggressively.

Rs.2,500 crores are the valuation figure that is being bandied around. If this agreement goes through Reliance Jio will get a jumpstart in the cable broadband business. Reliance Jio will get Hathaway’s massive digital cable TV and broadband user base where almost 90% of subscribers have over 40 Mbps of high-speed plans.

Not Reliance’s First Walk in the Park

Reliance had made an attempt to acquire another cable operator before Hathway. Last year in September RIL was in advanced talks with DEN Networks promoter Sameer Manchanda regarding a possible buy-out. When negotiations failed, Reliance Jio decided to launch Jio GigaFiber as a complete part of Reliance Jio Infocomm.

According to one of the internal sources, various business plans get discussed simultaneously at Jio. He revealed that Jio had earlier planned to purchase a big MSO and some smaller ones. They had mapped out on how the existing infrastructure of the MSO was to be used for providing broadband as well as video services.

Another source divulged that Reliance Jio faced resistance from LCOs (local cable operators). They wouldn’t let Jio proceed with its extension of the most important last-mile connectivity in crucial markets. This led to the delay in the GigaFiber roll-out. This is also why Reliance Jio is back in the market looking to acquire a cable operator.

According to a top brokerage firm’s media analyst, RIL has laid out the fiber and has an MSO license all ready. They are missing LCOs to reach the last mile. Acquisition of Hathway will solve that problem.

Autostart Glassfish on startup in Ubuntu

To make the Glassfish Server auto start with startup, we need to setting up an init script, which helps us to manage all Glassfish Server startup events easily. And also make Glassfish start up automatically whenever Ubuntu is rebooting.

This script file is glassfish to be created at /etc/init.d/. For managing all Glassfish Server startup events, it ships with the asadmin tool. Use this tool in the startup script as follows,

  1. Create or edit glassfish file
  2. Paste the following lines in the file

Now, glassfish startup script is created. We need to add this file in startup to make Glassfish Server autostart during Ubuntu startup. Follow these steps,

  1. Make the startup script file executable
  2. Add this file to Ubuntu startup boot

That’s it. Now, restart Ubuntu and check if it really autostart the Glassfish Server.

You can also manage Glassfish Server startup events as follows,

  • Start the server
  • Stop the server
  • Restart the server


Automatically start Tomcat on startup in Ubuntu

Apache Tomcat is not configured with autostart by default in Ubuntu. So, custom init script is required to configure Tomcat for autostart on startup.

Create the init script in /etc/init.d/tomcat8 with the contents as per below.

Init script contents:

Note: Please change {tomcat_root} with your Tomcat installation folder path.

Change its permissions and add the correct symlinks automatically:

And from now on it will be automatically started and shut down upon entering the appropriate run levels.

It could be also controlled with justservice tomcat8 <stop|start|restart> like Apache control commands.

Using above process any server script can be created and configured to start on startup.

Accessing PostgreSQL via SSH Putty tunnel

To close the port 5432 for any traffic or don’t want to configure PostgreSQL to listen to any remote traffic, use SSH Tunneling to make a remote connection to the PostgreSQL instance at AWS.

Follow these steps to connect PostgreSQL using SSH Tunneling at AWS:

  1. Open PuTTY. Setup server session in Putty.
  2. Go to Connection > SSH > Tunnels
  3. Enter 8000 in the Source Port field.
  4. Enter in the Destination field.
  5. Click the “Add” button.
  6. Go back to Session, and save, then click “Open” to connect.
  7. This opens a terminal window. After connection leaves that alone.
  8. Open pgAdmin and add a connection.
  9. Enter localhost in the Host field and 8000  in the Port field.
  10. Specify a Name for the connection, and the username and password. Click OK.
What is it doing? PuTTY is intercepting communications sent from pgAdmin to localhost:8000. The information is transferred across the internet via SSH, on port 22. When it arrives there, the SSH server sends the information on to PostgreSQL via port 5432. As far as PostgreSQL knows, the traffic came in locally, on the correct port.