如何设置apache的rewrite规格,当我访问url1时重定向到url2:
url1: http://topsu.com:9001/css/app.css
url2: http://static.topsu.com/css/app.css (注意没有端口)
补充:
1. topsu.com和static.topsu.com都指向本地服务器:127.0.0.1
2. 我在httpd-vhost.conf里已经作如下配置,但没起作用。浏览器仍然是访问了url1而没有重定向到url2。
<VirtualHost *:80>
ServerName static.xwanapp.com
DocumentRoot "${SRVROOT}/htdocs/xwanapp"
</VirtualHost>
<VirtualHost *:80>
ServerName xwanapp.com
ErrorLog "logs/xwanapp_error.log"
CustomLog "logs/xwanapp_access.log" common
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/css
RewriteRule /css/(.*) http://static.xwanapp.com/css/$1 [R=permanent,L]
</VirtualHost>