Jan 23, 2013

Redirect all urls to a single page index.php

When you create a web app if unwanted links or bad links you want to redirect to a script page ( for eg: php ). This is the method.

My document root is /var/www/ and my index.php page is on document root.
Create a file .htaccess at /var/www/ and add the following.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?_REQUEST=$1 [L]

save the file and then in terminal run sudo a2enmod rewrite

Then edit /etc/apache2/sites-available/default with an editor ( I used vim )

There in change AllowOverride None to AllowOverride all

Save it. Restart apache ( sudo /etc/init.d/apache2 restart ).

My environment is Ubuntu 10.04.

Reference:

For Web Developer

  open -a "Google Chrome" --args --disable-web-security