?
Solved

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

Posted on 2013-01-17
4
Medium Priority
?
220 Views
Last Modified: 2013-01-17
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
0
Comment
Question by:milani_lucie
  • 2
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38788404
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.
0
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 2000 total points
ID: 38788451
0
 

Author Comment

by:milani_lucie
ID: 38788674
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
0
 

Author Comment

by:milani_lucie
ID: 38789536
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
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month17 days, 7 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question