Reputation: 29
My question is about URL and Web. Sometimes i see URL as so: www.myweb.com/user.php?name=mark I understand that this way you can like take data from database where name is mark and display on site.
but other way is see is like this: www.myweb.com/user/mark
As i see it, it file named mark inside user folder, that somehow then displays from database all the info about guy named Mark, but what is really going on? How is it done so? Is it something to do with XML? When to use it so? Why to use it so?
I dont know even what to search in google, so any link is helpful.
Thank you
Upvotes: 0
Views: 52
Reputation: 190907
This is a common technique called url-rewriting that the web server can perform.
Wordpress does this and it translates
http://example.com/2013/04/27/foo
into something like
http://example.com/index.php?url=2013/04/27/foo
You can read up on in generalities on Wikipedia.
Upvotes: 1
Reputation: 3923
If talking about common Apache servers, the webserver has a file called .htaccess
or another one httpd.conf
capable of using Apache's built-in mod_rewrite
module for URL rewriting. The exact ways to do this can be specified in these files using RewriteCond
and RewriteRule
directives. The new URIs are just aliases for old ones. (There don't have to be actual folders for the given route)
Upvotes: 0
Reputation: 88
This is beacause of using .htacces This is a file that removes the query string and makes pretty URLs
Example:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} !no-redir [NC]
RewriteCond %{QUERY_STRING} (^|&)subject=([^&]+) [NC]
RewriteRule ^(.*)/product.php$ $1/%2? [NC]
RewriteRule ^([^+\s]+)(?:[+\s]+)([^+\s]+)((?:[+\s]+).*)$ $1-$2$3 [DPI,N]
RewriteRule ^([^+\s]+)(?:[+\s]+)([^+\s]+)$ $1-$2 [R=301,DPI,L]
Upvotes: 0
Reputation: 150108
user
and mark
are not "folders", but simply parts of the URL.
Some web servers follow a convention to look in the folder /user/mark (relative to some root folder) and serve a document from there.
However, it is becoming increasingly common for web platforms to interpret the URL differently. The exact interpretation is depends on the specific web platform.
Such web platforms simply map parts of the URL to server resources using a platform-defined convention.
In ASP.Net (the platform I am most familiar with), that mapping is called routing.
ASP.NET routing enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.
Upvotes: 1