0

Im just surfing in the internet and i notice some url is form like this "samplesite.com/myname" is that "/myname" is a kind of diretory? is that mean that when someone successfully register in facebook.com they also create directory in thier server(facebook.com)? then my last question is, when i use some website like posting article website, after i successfully save or create an article, the url became like this, article.com/my-title-article.html, is that mean that when i successfully save my article, also the sive have some piece of code that enable the user to create its own html file? thank you, and sorry for my bad english

6 Answers 6

1

"Fancy url's" are made using a rewrite engine. An example is the rewrite engine of apache. See mod_rewrite for more information about that. It rewrites the url (e.g. samplesite.com/myname) internally to a file it can exeute (e.g. samplesite.com/person.php?name=myname). The same rewrite engine can be used to rewrite ugly url's (like the last one) to fancy url's.

Sign up to request clarification or add additional context in comments.

Comments

1

When you go to http://samplesite.com/myname, your browser just sends a GET request to samplesite.com and asks for the resource located at /myname. From there, it's entirely up to the webserver to determine what exactly that "resource" is.

Webservers like Apache, Nginx, Lighttpd, etc. can be configured to serve static files the way you described (i.e. treating /myname as a path), but the webserver can also be a reverse proxy that stands in front of a web application running on the server.

/myname can be a folder, but that's up to the webserver to implement. Similarly, my-title-article.html can be a generated HTML file, but it doesn't have to be. The server could extract my-title-article, query a database for an article with that slug, and return a generated webpage.

2 Comments

for example i successfully save my article, then it actually save in database, but why the current url become article.com/my-title-article.html?
@RobertJohnConcepcion: Why not? The URL is just a URL.
0

url can be modified using rewrite rules in .htaccess file and you can learn about the same from- http://en.wikipedia.org/wiki/Htaccess

http://httpd.apache.org/docs/current/howto/htaccess.html

Comments

0

Im just surfing in the internet and i notice some url is form like this "samplesite.com/myname" is that "/myname" is a kind of diretory?

Not necessarily, but possibly. It could be that the site uses a framework like django, in which case myname is passed to the framework and parsed, and there is no literal directory structure at all corresponding to the URLs.

is that mean that when i successfully save my article, also the sive have some piece of code that enable the user to create its own html file

Almost certainly not. What is happening there is that your article is written to a database and retrieved. It is not saved on the web site as html.

Comments

0

These URL are there to make you feel LIKE if some directories & files were created, because it makes them more user friendly and easy to remember, but new ones are almost (always?) never created.

Without that your article link would be something like article.com/?id=456789, less easy to remember and less nice to read.

Comments

0

Another way to change the URL completely, defacing it from its default, is using a good framework for development, such as CodeIgniter, CakePHP or YII. These frameworks come with features that facilitate the manipulation of the URL.

For example, the site Amithings developed the UPL (URL Programming Language), which runs in a single line on the URL.

Example: http://www.amithings.com/information(2wnCfB).rows(1-10,16-30,31)/view(html)/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.