PHP Redirect to url ending .htm

rubywolff

New Member
Joined
Dec 19, 2007
Messages
2
Reaction score
0
Hi,
I have the below code to redirect a submit form to a new URL. The problem i cannot get around is that the files i am trying to redirect to end in .htm

Could any1 please help me to figure out how to amend this so that you put in the name of the file but it ends the url in .htm for you. the best i can do is get it ending in VAL01htm but not VAL01.htm.
Sad

<?php
if(isset($_POST['Submit'])){
$base = "http://localhost/AirBIZ%20Site/Data/";
$url = $base . $_POST['url'];
$file = @fopen($url,"r");

if($file){
header("Location: $url");
}
else{
$err = "$url URL does not exist";
}
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Track and Trace</title>
</head>

<body>
<?php
if(isset($err)){
echo $err;
}
?>
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="url" />
</label>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</form>
</body>
</html>

Thanks
Ruby
 
You can simply make the server parse htm files looking for php code.
Add the following line:
AddType application/x-httpd-php .php .php3 .htm to a file called .htaccess in the directory the .htm file is located. You can name as many file extensions as you like. Whether it will work depends on your host, some don't allow you to modify server behavior like that.
 
Hi Anthropoid,
Thanks for that info.
I am just testing the tracking on wamp at the moment. Where will i find the htaccess file there?

Sorry to be a pest.

If this does not work is there not a code that would end the url in the htm.
Its weird i can do a search on VAL01.htm and it will pull up that page for me. but when i type in VAL01 alone it cannot find the URL cause of the darn .htm at the end.
 
Where will i find the htaccess file there?

It should be located under the /public_html directory. Also, remember make sure your FTP client is configured to view invisible files ;)

Good luck!
 
Top
Sign up to the MyBroadband newsletter
X