Originally posted by geeknews
I am trying to do a redirect from one directory to the other.
anydomain.com/dp to anydomain.com/forum
Any help would be appreciated.
If it's on the same domain, just switching directories is quite easy using either rewrite or alias directives.
Note: for non-SSL site use vhost.conf, for SSL use vhost_ssl.conf. This example will assume you have already created and populated the /forum directory, and the /dp directory does not even have to exist.
USING ALIAS:
Edit or create the /home/httpd/vhosts/anydomain.com/conf/vhost.conf
Contents:
Code:
Alias /dp /home/httpd/vhosts/anydomain.com/httpdocs/forum
Then execute
Code:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=anydomain.com
which will update the necessary Apache files with the vhost changes.
Finally, restart Apache (either from the control panel, or from the command line) On RH systems, 'service httpd restart' or '/etc/init.d/httpd restart'.
USING REWRITE:
Edit or create the /home/httpd/vhosts/anydomain.com/conf/vhost.conf
Contents:
Code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteCond %{REQUEST_URI} ^/stuff$
RewriteRule ^/dp$ /forum [R,L]
</IfModule>
If you wanted to go from anydomain.com/dp to anotherdomain.com/forum, this can also be done, just requires different statements. such as:
Code:
RewriteCond %{REQUEST_URI} ^/dp$
RewriteRule ^/dp$ [url]http://anotherdomain.com/forum[/url] [R,L]
Then execute
Code:
/usr/local/psa/admin/sbin/websrvmng -u --vhost-name=anydomain.com
which will update the necessary Apache files with the vhost changes.
Finally, restart Apache (either from the control panel, or from the command line) On RH systems, 'service httpd restart' or '/etc/init.d/httpd restart'.
For more information on Apache's rewrite features:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html