我有很多redirect工作,但我有一个需要redirect,并删除文件名。
redirect 301 /path/to/file/default.aspx http://www.domain.com/newpath/to/page/
当我实现它时,它会尝试redirect,但不会从URL中删除default.aspx。
编辑
重写规则:
## path relative to web root RewriteBase / ## workaround for HTTP authorization ## in CGI environment RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] ## always send 404 on missing files in these folders RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ ## never rewrite for existing files, directories and links RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l ## rewrite everything else to index.php RewriteRule .* index.php [L]
编辑2
唯一的其他指令将在虚拟主机configuration,并没有很多:
<VirtualHost 192.168.100.216:80> ServerName web01.domain.com ServerAlias www.domain.com DocumentRoot /var/www/domain.com/htdocs SetEnvIf X_FORWARDED_PROTO https HTTPS=on RewriteEngine on <Directory /var/www/domain.com> AllowOverride All </Directory> </VirtualHost>
Redirect
文档说
超出匹配的URLpath的其他path信息将被追加到目标URL。
所以你的Redirect
行添加了不需要的文件名。
试试这个:
RewriteCond%{REQUEST_URI} ^ / path / to / file / default.aspx $ RewriteRule。* http://www.domain.com/newpath/to/page/