url format issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

mmm... it looks like both me and superdizign have been trying to solve this problem like rookies :oops: :oops:

I stoped for a while and made some http requests using command line curl.
It really is trivial.
if http://mysite.com/path is a directory then the server answers a 301 and specifies the Location. Most of the clients will redirect the user to that location.

This means... i have to handle redirections... buuuh... more boring codding ahead.

I hope this thread to be of interest of other people having the same existential questions.

Thanks superezign for the chat :D
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I don't believe it is possible. So many pages are dynamically generated these days. Any front controlled app for instance will direct all requests whether they look like directories or not to a single file. Ultimately though every request goes to a file the one that look like they are going to a directory are actually going to files only the web server configuration is choosing what that file is (usually index.html, index.htm or index.php)

Why do you need to know this?
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

ole wrote:I don't believe it is possible. So many pages are dynamically generated these days. Any front controlled app for instance will direct all requests whether they look like directories or not to a single file. Ultimately though every request goes to a file the one that look like they are going to a directory are actually going to files only the web server configuration is choosing what that file is (usually index.html, index.htm or index.php)

Why do you need to know this?
I wanted to know this in order to follow relative links properly.
It's not really a mater of how the sites are coded, it's more about the http protocol itself and the way webservers inplement it.

The problem is solved though. Read my last post.

Often we browse and even include links on sites like: http://mysite.com/dir when we want to point to http://mysite.com/dir/ . The servers handle this ambiguity by repplying a 301 error code ( permanently moved ) and providing the location. The browsers simply redirect you to the right location.

A directory url must allways end with a slash.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Oh yeah sorry I should have read your post. That's very interesting actually. Thanks for that.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I tried cURL, but I guess you've got better luck than me. I was just looking at the headers after your suggestion that it may be there.

There are way too many CURLOPTs. Makes my head spin.
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

superdezign wrote:I tried cURL, but I guess you've got better luck than me. I was just looking at the headers after your suggestion that it may be there.

There are way too many CURLOPTs. Makes my head spin.
ehehe... who forgot to read the documentation? .... both of us :lol:

the option is -I or -head

try this on command line:

Code: Select all

curl -I http://java.sun.com/reference/docs/
it will download the page itself, look at the headers on top

now compare with this

Code: Select all

curl-I http://java.sun.com/reference/docs
allways check the good old friend man page

Code: Select all

man curl
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Whoa. The guy who design cURL went all out. :)
Post Reply