Hiding PHP extension

Topics: User Forum
Apr 5, 2008 at 8:56 AM
Edited Apr 5, 2008 at 10:15 AM

We have a website http://ecards.srch.in/index.php?querystring=value. Now we want to modify all these links making them look like an ordinary link to a static file with .html extension. For example the site should look like http://ecards.srch.in/somepage-value.html. We have installed the ISAPI dll in a windows 2003 (R2) SP1 and IIS 6 environment with Plesk 8.3. Can somebody help us what rule should we write to implement this.

Thanks in Advance
Apr 8, 2008 at 2:35 PM
You'd probably want a rule that looks something like this (I'm guessing at what your query-string may be...):

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(\w+)-(\w+).html$ /index.php$1=$2

What we're doing is checking if the file exists and is a regular file and if the path is a directory (probably could remove 2nd line) and then if found false (because the file wouldn't exist anyways), we'd rewrite the URL to your processing page.

Depending on what you expect in the query-string (words, numbers, characters, etc...), you'd have to adjust the Regular Expression.

Best of luck.