Tag Archives: htaccess

Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration

Apache shows this error message when you don’t have mod_rewrite enabled. To enable it follow below steps

1. cd to apache2 (usually in cd /etc/apache2 )

2. enter this command – sudo a2enmod rewrite

3. now restart the apache service – sudo service apache2 restart

That’s it !

 

How to enable mod_rewrite in Apache?

To enable it the rewrite module, run “apache2 enable module rewrite”:

You need to restart the webserver to apply the changes:

If you plan on using mod_rewrite in .htaccess files, you also need to enable the use of .htaccess files by changing AllowOverride None to AllowOverride FileInfo. For the default website, edit/etc/apache2/sites-available/default:

 

After such a change, you need to restart Apache again.

Ref: http://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache

Remove index.php from Codeigniter url

To remove “index.php” from codeigniter url

Open application/config/config.php file and look for following section in the file

Remove the index.php and save the file

Now create an .htaccess file and paste  following lines

Save this file into root directory of your project, after creating this file restart your web server.

Redirect website to https from cpanel or htaccess file or php

If you want to redirect using htaccess, add following lines in the htacess files

We can also redirect  using php code in out header file

To redirect from cPanel,

Log into your websites control panel, then go to “Domains” section. Click on “Redirects” option

– Select type “Permanent (301)” from dropdown menu

– Select domain name which you want to redirect

– And finally enter the url to which you want the above select domain redirect to