Redirect Subdomain to Subdirectory

To redirect a subdomain to a subdirectory, use following .htaccess code.

Redirect Subdirectory to Subdomain

See htaccess […]

Read More…

React/Angular Application showing 404 error on refresh

On Apache server, React Application works fine, but if you refresh a page, it shows 404 error. This is because the application use BrowserRouter. To fix the error, create a .htaccess file with following content

Put this on the folder where your application index.html is or in Apache Virtual Host entry. See htaccess […]

Read More…

Redirect a folder to another

To redirect a folder to another using .htaccess, create

Or

Or

if new folder is on another domain, you can use https://new-domain.com/OLD_FOLDER See Redirect […]

Read More…

Password Protect Site using htaccess

To password protect a web site or a sub folder using .htaccess, create a .htaccess file in the folder.

Add following content

In this case, i used /etc/apache2/site-logins as AuthUserFile, this will store all user and password. You can change this file path to whatever you need. Make sure it is not accessable […]

Read More…

Redirect site to HTTPS excluding a folder

On a web site, customer need to redirect all pages to HTTPS, but want to keep files in one of the folder on HTTP. For this, i used following in .htaccess file.

Here any url like yourdomain.extn/auth/ will not get redirected to HTTPS. See Redirect […]

Read More…