« Previous | Next»

How to check if you have ModRewrite

Posted by coldtobi | 12 Jul, 2008, 18:58

ModRewrite comes handy for SEO and other opportunites, where you want to change URL to something else. Lifetype uses this to assemble all the php parameters and make more search-engine and humanfriendly URLs. Also, you can do the RFI Protection I described earlier.
To find out, whether your webhoster's Apache supports ModRewrite, you have basically two options:


Ask them
Well, you won't get the answer instantly.... But you could akso check your plan, maybe it states something...

Try it out.

You can also test it by yourself is two steps:

1) Check for .htaccess support

You'll need working .htaccess support to utilize ModRewrite. Create an empty directory in your webspace (name it "test"), create a index.html in this directory. Try to show the page in your web browser to confirm that it works.

After that, create in your test-direcroy a .htaccess file. (That is "dot-htaccess") with this content:

<Files *>
deny from all

(If you have problems to generate a filename starting with a "dot" in the name, you probably have Windows. To overcome this, just use any filename, upload it to the website and then rename the file to .htaccess on the webserver.)

Now, check if you can still access your test file:
If you get "Access Denied", your hoster supports htaccess. If you get the page as before, you don't have .htaccess (or mispelled the name) Maybe you should write your hoster asking if they could enable it for you. Or you should change your hoster.

2) Check for mod-rewrite.

Edit your .htaccess that it reads.
RewriteEngine On
Rewrite test.html index.html
Safe the file and retry accessing your test file from step 1, but using the URL "test/test.html"
If you get your "index.html" from before, ModReWrite works.

If you got a "500", "Internal Server Error", check your .htaccess. If it's messed up, apache will complain with this error. If the file is ok, Mod_Rewrite is not available.

A "404", File not found is an indication that you mispelled some filename.
  • Check the filenames in the htaccess, in the server's directory
  • Check the URL you've entered in the browser.
  • Check is you correctly named your .htaccess (you didn't omit step 1, did you?)

Linux / Debian, Blog and Website, Tips and Tricks | Comments (2) | Trackbacks (0)

Related Articles:

2 Comments | "How to check if you have ModRewrite" »

  1. zainic : check htaccess support

    18/02/2009, at 10:01 [ Reply ]

    i need php script for checking compatibility of htaccess on the web server ?

  2. David Smith :

    20/04/2010, at 05:28 [ Reply ]

    I was searching for it for last 2 hours and finally i got it. Thank you so much. Very good article for beginners