Apache:除了RewriteRule的路径

时间:2011-07-07 15:53:03

标签: mod-rewrite apache2 apache

如果您访问/portal/,我会尝试重定向到/sitemapHT/,但似乎此过程^(/$|!sitemapHT)错误,因为它仍然将我重定向到/ portal /

<VirtualHost *:80>
        DocumentRoot "/opt/tomcat-5.5.30/webapps/portal"
        ServerName hoteles
        ServerAlias hoteles

        JkUnMount       /images/*.gif           w1
        JkUnMount       /images/*.png           w1
        JkUnMount       /images/*.jpg           w1
        JkUnMount       /js/*.js                w1
        JkUnMount       /styles/*.css           w1


        JkMount         /portal                 w1
        JkMount         /portal/*               w1


        RewriteEngine on
        RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
        RewriteRule .* - [F]
        Options +FollowSymlinks

        RewriteRule   ^(/$|!sitemapHT)  /portal/  [R]
        RewriteRule ^/(?!portal)(.*) /portal/ficha.action/$1 [PT]

</VirtualHost>

你能否建议我进行适当的纠正?

谢谢!

1 个答案:

答案 0 :(得分:1)

我希望我能正确理解你:

RewriteCond $1 !^/(sitemapHT/|portal/)
RewriteRule ^(.*) /portal/ [R,L]

这会将所有传入的请求重定向(302代码)到/portal//sitemapHT/或直接请求/portal/


<强>更新

RewriteCond $1 !^/(sitemapHT/|portal/)
RewriteRule ^(.*) /portal/ [R,L]
RewriteCond $1 !^(sitemapHT/|portal/)
RewriteRule ^/(.*) /portal/ficha.action/$1 [PT]

使用上述规则代替最后两行:

RewriteRule ^(/$|!sitemapHT) /portal/ [R]
RewriteRule ^/(?!portal)(.*) /portal/ficha.action/$1 [PT]