trailing slashes in url
Moderator: General Moderators
trailing slashes in url
I wondering how to detect trailing slashes in the url.
ie.
localhost/index.php <-- this is good, php finds the includes etc, and images are displayed
localhost/index.php/ <-- this is bad, php find the includes etc, BUT images do not load etc since the base for the html is thrown out.
This issues affects may php sites (not phpBB).
What do I do?
Ps. Did search this site but didn't find anything.
ie.
localhost/index.php <-- this is good, php finds the includes etc, and images are displayed
localhost/index.php/ <-- this is bad, php find the includes etc, BUT images do not load etc since the base for the html is thrown out.
This issues affects may php sites (not phpBB).
What do I do?
Ps. Did search this site but didn't find anything.
feyd | Please use
Access this code, say "index.php" and the graph image will be displayed twice.
Access this code as index.php/ and then the images will not be displayed, nor will css etc.
I tried this on phpMyAdmin and it just hung.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, ok
He is some code, very simple.Code: Select all
<?
echo "hello";
echo "<img src=\"graph.png\">";
?>
<br>
<img src="graph.png">Access this code as index.php/ and then the images will not be displayed, nor will css etc.
I tried this on phpMyAdmin and it just hung.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Your src attributes contain relative urls, i.e. the browser appends the new path to the current path.
http://localhost/index.php <- index.php is the file part of the url, src="graph.png" -> http://localhost/graph.png
http://localhost/index.php/ <- empty file part, src="graph.png" -> http://localhost/index.php/graph.png
http://localhost/index.php <- index.php is the file part of the url, src="graph.png" -> http://localhost/graph.png
http://localhost/index.php/ <- empty file part, src="graph.png" -> http://localhost/index.php/graph.png
Why would anybody call index.php/?
Take a look at
Take a look at
Code: Select all
echo 'REQUEST_URI: ', $_SERVER['REQUEST_URI'], " <br />\n";
echo 'PATH_INFO: ', $_SERVER['PATH_INFO'], " <br />\n";- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Code: Select all
rtrim($string, '/');Why no absolute path?
Code: Select all
<img src="/graph.png">