I am wondering how web addresses such as these are produced: http://www.example.com/Xj7hF

This can be a practice I've come across used by lots of url shorteners along with other websites that allegedly don't wish to display data within the url inside a parameter format.

Surely they cannot be placing index files within the folder destination /Xj7hF etc having a redirect towards the actual url, so I am wondering how this is accomplished.

Any help could be very appreciated!

(I am running on the Linux server with Apache).

This is whats called URL rewriting and it is usually carried out via proper configuration from the webserver. StackOverflow has several tags with this, which means you should have the ability to find more details there.

Different web design frameworks and web servers get it done diversely, but, the most typical is most likely using mod_rewrite with apache. Essentially, the net server transmits the request to some dynamic scripting language (eg. PHP) rewritten in a way the script does not have to know exactly what the original request URI appeared as if and also the client browser does not have to know what script really processed the request.

For instance, You'll frequently see:


This can be a request /123 which Apache may rewrite like a request to /my_script.php?id=123 depending on how the consumer set up mod_rewrite.

(.htaccess example)

# if the request is for a file or directory that
# does not actually exist, serve index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1

I usually assumed the request delivered to the container could be converted server side with a kind of redirect, or perhaps in the situation of the internal redirect to some specific response within the application. Everything is dependent around the framework though.