http://example.com/inst/photogallery/viewphoto?photoid=1235 http://example.com/inst/photogallery/viewcomments?photoid=1235 http://example.com/inst/photogallery/admin?photoid=1235&method=delete
The main idea of a redirection is telling the web client to go to another URL when the requested URL matches a rule.
http://example.com/inst/photogallery/viewphoto?photoid=1235 http://example.com/inst/photogallery/viewcomments?photoid=1235 http://example.com/inst/photogallery/admin?photoid=1235&method=delete
http://example.com/photo/1235 http://example.com/photo/1235/cmts http://example.com/photo/1235/delete
This directive uses PCRE (Perl Compatible Regular Expressions) to make the substitution.
Type: [External | Internal]
Internal: The redirection will happen internally, hence the internal URL in which the address is translated will be invisible for the client.
External: It works in the same way as the previous one, but in this case, it will redirect the connection to the new resource.
Regular Expression and Substitution are the matching request and the intended target of such petition.
The internal redirections, using the internal keyword, are limited to work in the same virtual host. All the internal redirections will be processed in the original virtual host, which makes a lot of sense in terms of security.
In case you do need to redirect a resource to another virtual host and/or domain, you will have to use an explicit redirection using the external keyword.
This example will perform internal redirections:
Regular Expression | Substitution |
---|---|
"/(d+)$" | http://example.com/inst/photogallery/viewphoto?photoid=$1 |
"/(\d+)/cmts" | http://example.com/viewcomments?photoid=$1 |
"/(\d+)/delete" | http://example.com/inst/photogallery/admin?photoid=$1&method=delete |
Which would translate into the following redirections for the listed matching requests:
Request | Internal translation |
---|---|
/photo/123 | http://example.com/inst/photogallery/viewphoto?photoid=123 |
/photo/213/cmts | http://example.com/viewcomments?photoid=213 |
/photo/501/delete | http://example.com/inst/photogallery/admin?photoid=501&method=delete |