I have a site with URL abc.com. Now what I want is whenever that URL is being hit in browser it should redirect to www.abc.com/index.jsp. How this can be done using apache ?
Here's what I have done:
VirtualHost *:80>
ProxyRequests off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel error <Location /> Options +ExecCGI AddHandler cgi-script .cgi AuthType basic AuthName "private area" AuthUserFile "/etc/httpd/conf/.htpasswd" Require valid-user </Location> </VirtualHost>
add this in your .htaccess in the root of the page
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
EDIT:
can also use this at the end of your vhost file:
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.