Jump to content

str_replace() on url string results in 403 Forbidden Error


justravis

Recommended Posts

i'm trying to strip out the first part of the url.

 

i tried submitting 'http://ref.potech.com/php/test.php'

 

Any ideas?  Thanks!

 

<html>
<body>

<?php

if($path)
{
$path=str_replace('http://ref.potech.com/php/', '', $path);
echo $path;

echo '<br><br>';
}

?>

<form action=<?php echo $PHP_SELF ?> method=get>
<b>PHP File URL (w/o 'http://'):</b> <input type=text name=path id=path>
<input type=submit name=submit id=submit value=Submit>
</form>
</body>
</html>

 

Error Page for the Page Coded Above:

Forbidden

 

You don't have permission to access /php/highlight_file.php on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Link to comment
Share on other sites

I don't understand what you are trying to achieve but the permission thing could be due to file permissions on the server.  Does the Web server own the file?

 

If you are just trying to get the file name I guess you could explode it on / and take the last chunk.  I'm sure there is a better way.

Link to comment
Share on other sites

i dont hav ssh access...u know how to determine file ownership from cpanel?

 

just realized if i manually pass the url to str_replace(), i dont get the error:

echo str_replace('http://ref.potech.com/php/', '', 'http://ref.potech.com/php/highlight_file.php');
echo str_replace('http://ref.potech.com/php/', '', 'http://ref.potech.com/php/arrays/multidim.php');

 

the error comes up when i submit the url in the form and pass it in the variable $path

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.