Link to home
Start Free TrialLog in
Avatar of milani_lucie
milani_lucieFlag for United States of America

asked on

How to map "http://SampleWebSite.com/Test" to "http://SampleWebSite.com/Test.htm" - PHP

Hi,

When users request the URL like this

http://SampleWebSite.com/Test

then, i want to map that one to

http://SampleWebSite.com/Test.htm

in PHP. Can you please provide me sample code for that ? And let me know where i have to make changes.

Thanks
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

As I told you in your other question, PHP can not do this.  It must be done by the web server in order to avoid getting a "404 File Not found" error.
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of milani_lucie

ASKER

I have this code in htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

But it never works for me. When user hits by using this URL:

http://Site1.com/knowthecode

It is not picking up the

http://Site1.com/knowthecode.html

file. Can you point me in right direction ?

Thanks
DaveBaldwin,

Can you please let me know how to set that (Redirection) in IIS. If you hit a page then we can have code in that page to handle the redirection. But my url is just :  http://Site1.com/knowthecode

Thanks