Difference between Aliasing, Redirecting and Rewriting in Apache
Aliasing refers to mapping a URL to a particular directory
Redirecting refers mapping a URL to another URL
Rewriting refers to using mod_rewrite module to alter an URL
Aliasing
Alias directive helps with aliasing as follows
1) To map URLs to a directory outside of the DocumentRoot directory tree
Eg:
To view the directory contents of user xyz through an URL, add the following entries in httpd.conf file
Alias /xyz /home/xyz
<Directory "/home/xyz">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Access the directory contents of user xyz as follows now
http://localhost/xyz
2) Helps in accessing the same content using different names
Eg:
Alias /abc /home/xyz
Now both the URLs show the same content
http://localhost/xyz
http://localhost/abc
Redirecting
Redirect maps a URL to another URL. The second argument to Redirect directive is a full URL.
Eg:
I want all requests coming to URL, http://localhost/xyz to be redirected to http://anonexp.blogspot.com
http://localhost/xyz ----> http://anonexp.blogspot.com
In httpd.conf file, make the following entry
Redirect "/xyz" "http://anonexp.blogspot.com"
From access_log file, we can confirm the redirection from 302 status
192.168.1.4 - - [03/Mar/2013:07:53:16 +0530] "GET /xyz/ HTTP/1.1" 302 290 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0"
Aliasing refers to mapping a URL to a particular directory
Redirecting refers mapping a URL to another URL
Rewriting refers to using mod_rewrite module to alter an URL
Aliasing
Alias directive helps with aliasing as follows
1) To map URLs to a directory outside of the DocumentRoot directory tree
Eg:
To view the directory contents of user xyz through an URL, add the following entries in httpd.conf file
Alias /xyz /home/xyz
<Directory "/home/xyz">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Access the directory contents of user xyz as follows now
http://localhost/xyz
2) Helps in accessing the same content using different names
Eg:
For the example shown above, suppose I want to access the contents of user "xyz" with name "abc" in httpd.conf file as follows
Alias /abc /home/xyz
Now both the URLs show the same content
http://localhost/xyz
http://localhost/abc
Redirecting
Redirect maps a URL to another URL. The second argument to Redirect directive is a full URL.
Eg:
I want all requests coming to URL, http://localhost/xyz to be redirected to http://anonexp.blogspot.com
http://localhost/xyz ----> http://anonexp.blogspot.com
In httpd.conf file, make the following entry
Redirect "/xyz" "http://anonexp.blogspot.com"
From access_log file, we can confirm the redirection from 302 status
192.168.1.4 - - [03/Mar/2013:07:53:16 +0530] "GET /xyz/ HTTP/1.1" 302 290 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0"
No comments:
Post a Comment