Sunday, March 9, 2014

How to check for mod_rewrite is enabled or not.

How to check for mod_rewrite is enabled or not.

1- First of all create an empty file and name it test.html (or what you want) and upload this file on you hosting server.
# touch test.html

2- Create a .htaccess file and put the following code into it. (create htaccess.txt file )
#touch .htaccess
-------------------------

RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]
------------------------
Note: On windows machine first create htaccess.txt file, then adds the above code into it, upload on server, after uploading remove the .txt extension.

3- Now run this URL into your browser http://www.domain-name.com/test.html (replace domain-name.com with your actual domain name).

If it redirects you on google.com then "mod_rewrite" is working on your server host, if it is not, shows you a blank file means mod_rewrite is not working.

4- If your site runs in some folder then adds the folder name before test.html and uploads the htaccess file in the root folder. Eg
-------------------------

1
2
3
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^foldername/test\.html http://www.google.com/? [R=301,L]
-------------------------