Tag Archives: .htaccess

.htaccess – Redirect all URLs to a specific sub domain

Sometimes you may have multiple domains which you want to use for your website or web application. Probably you needed to park the domains on your hosting cpanel. In this case, you website or web application could be access by more than one domain which is not good for SEO and other 3rd party services may not work.

A simple way to redirect all URLs to a specific URLs is by .htaccess.

Suppose you have the following sub domains and all of them serve your website or web application.

Continue reading .htaccess – Redirect all URLs to a specific sub domain

Advertisements

Nginx – Setup HTTP Authentication

HTTP Authentication is the easiest way to prevent anonymous user access to your website. If you are on Apache, you can refer to the following post.
.htaccess – Setting Password For Your Web Folder

After you have created the password file, you could add the following line in the .htaccess or in the Apache VirtualHost.
Continue reading Nginx – Setup HTTP Authentication

.htaccess – Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

I have a previous post which demonstrates how to add HTTP Authentication by .htaccess.
.htaccess – Setting Password For Your Web Folder

But if it does not work and shown the following error in the Apache error log

  • /home/ykyuen/public_html/.htaccess: Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

Continue reading .htaccess – Invalid command ‘AuthUserFile’, perhaps misspelled or defined by a module not included in the server configuration

Google – How to fix “This site may harm your computer”

If your website is marked as “This site may harm your computer” by Google, most likely your site is hacked. In that case, log in to Google Webmaster Tools and it will shows you which URLs are “infected”. This should help a lot to clean the malware.

So make sure you have configured Google Webmaster Tools for your live websites. Continue reading Google – How to fix “This site may harm your computer”

Drupal – Override the php.ini

I was working for a Drupal website which i wanted to increase its maximum file upload size. This value is determined by the php.ini configuration file.

Unfortunately, the server hosting does not provide the SSH access so i can’t edit the php.ini. Therefore i have to let Drupal override the php.ini settings. There is 2 ways for Drupal to override the php.ini settings. Continue reading Drupal – Override the php.ini

Apache – .htaccess VS httpd.conf

So if both .htaccess and httpd.conf can serve the same purpose (Apache – Disable Directory Listing), which one should we pick?

On performance point of view, .htaccess is read every time when the directory is loaded. and each directory can have it own .htaccess. so this may cause a performance hit but seems that it is not very significant.
The Fubra Blog – .htaccess vs httpd.conf

On the other hand, the situation may bother your choice. Not every user got the permission on writing the httpd.conf file and they may even do not have the right to restart the Apache Server. In this case, you have to use .htaccess to restrict the access right.

Here is a summary comparing .htaccess and httpd.conf. Continue reading Apache – .htaccess VS httpd.conf