【发布时间】:2012-05-15 02:15:22
【问题描述】:
如果我的重写 url 没有尾部斜杠,则它不会重定向。
我想将到这里http://example.com/po 的用户重定向到这里:http://new.example.com/po/index_mi.php。
我尝试了这些行,但没有一个起作用:
RewriteRule /po(/)?$ http://new.example.com/po/index_mat.php [R=301,L]
RewriteRule ^/po(/)$ http://new.example.com/po/index_mat.php [R=301,L]
RewriteRule ^/po$ http://new.example.com/po/index_mat.php [R=301,L]
这是完整的虚拟主机:
<VirtualHost 192.228.100.142:80>
ServerAdmin serveradmin@example.com
DocumentRoot /home/drupal_1
ServerName example.com
ServerAlias www.example.com
Alias /movies /home/movies/
ErrorLog /var/log/httpd/example.com_err_log
CustomLog /var/log/httpd/example.com_log special
<Directory /home/drupal_1>
Options FollowSymLinks Includes ExecCGI
AllowOverride All
DirectoryIndex index.html index.htm index.php
</Directory>
# Rewrite Rules #####################
RewriteEngine On
RewriteRule ^/webmedia/(.*) / [R=301,L]
RewriteRule ^/marquee.php / [R=301,L]
RewriteRule ^/register /user/register [R=301,L]
RewriteRule ^/po(/)?$ http://new.example.com/po/index_mat.php [R=301,L]
# end Rewrite Rules #################
</VirtualHost>
更新:
我得到了它与这条线的合作:
RewriteRule ^/po$ http://new.example.com/po/index_mat.php [R=301,L]
【问题讨论】:
标签: mod-rewrite redirect virtualhost slash