Previously I wrote Rewriting tips using .htaccess file for URL rewriting.
Common Usage of .htaccess file :
– Authorization, authentication
– Rewriting URLs
– Directory listing
– MIME types
– Cache Control, and many more.
Here is a test to check that .htaccess or mod_rewrite is enabled on any type of hosting whether shared or dedicated.
Now we want 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.
2- Create a .htaccess file and put the following code into it. (create htaccess.txt file )
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
RewriteRule ^foldername/test\.html http://www.google.com/? [R=301,L]