Friday, April 19, 2013

.htaccess issue - html links are not working

.htaccess - Menu Links are not working


.htaccess links defined in rewrite-rules are not working in apache2

1) Enable rewrite module
   $ sudo a2enmod rewrite    $ service apache2 restart


2) These lines should be in /etc/apache2/apache2.conf
AccessFileName .htaccess <Directory /var/www>     AllowOverride All     #AllowOverride None </Directory> 
Restart apache2.

3) Enter following lines in /etc/apache2/httpd.conf

<Directory /var/www/project-name>     AddHandler cgi-script .cgi     Options +Indexes +ExecCGI     AllowOverride all </Directory> 

4) "AllowOverride all" should be uncommented in apache2.conf or httpd.conf.

.htaccess issue - The character encoding of the HTML document was not declared

Error: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.Source File: http://localhost/path/of/the/project/    Line: 0


The website dos not load the css and it looks distorted when .htaccess file is used for web project.

To solve this error:
Add following line in your apache configuration file.
/etc/apache2/apache2.conf or /etc/httpd/conf/httpd.conf (according to your linux distribution)
AddHandler application/x-httpd-php .htm

Restart Apache.

Enable authentication in apache2 using .htaccess

.htaccess is not working in apache2 :

If you have put .htaccess in your web project directory and it does not ask for username & password.
Follow this.

1) Check following directives in /etc/apache2/sites-available/default
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>
   Where /var/www is path of the directory where you keep your web projects.

2) Add following directive in httpd.conf
<Directory /your/path/of/the/project> AllowOverride All </Directory>

3) Restart apache2.