Mod rewrite VirtualHost中用于目录重定向的Apache重写规则在没有尾部斜杠的情况下不起作用

Mod rewrite VirtualHost中用于目录重定向的Apache重写规则在没有尾部斜杠的情况下不起作用,mod-rewrite,redirect,virtualhost,slash,Mod Rewrite,Redirect,Virtualhost,Slash,我拥有的重写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 [

我拥有的重写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]
以下是完整的vhost:

<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>
尝试:

从:

AllowNoSlash

默认情况下,mod_rewrite将忽略映射到上的目录的URL 磁盘,但缺少尾随斜杠,期望mod_dir 模块将向客户端发送一个重定向到规范URL的命令 尾随斜杠

directorysash
指令设置为
off
时,
AllowNoSlash
可以启用选项以确保不再使用重写规则 忽略。此选项可以在中应用重写规则
.htaccess
与目录匹配但不带尾随斜杠的文件,如果 如此渴望

在Apache HTTP服务器2.4.0及更高版本中提供

尝试:

从:

AllowNoSlash

默认情况下,mod_rewrite将忽略映射到上的目录的URL 磁盘,但缺少尾随斜杠,期望mod_dir 模块将向客户端发送一个重定向到规范URL的命令 尾随斜杠

directorysash
指令设置为
off
时,
AllowNoSlash
可以启用选项以确保不再使用重写规则 忽略。此选项可以在中应用重写规则
.htaccess
与目录匹配但不带尾随斜杠的文件,如果 如此渴望

在Apache HTTP服务器2.4.0及更高版本中提供

看来您必须重新启动Apache,或者至少进行一次优雅的重新启动才能生效


看来您必须重新启动Apache,或者至少进行一次优雅的重新启动才能生效。

我不确定该行在vhost conf文件中的何处。我试着把它放在“引擎打开”下,但没用。感谢当我在“RewriteEngine On”下添加这一行并重新启动Apache时,它给了我一个错误RewriteOptions:未知选项“AllowNoSlash”。好消息是我现在不用它就可以工作了。我使用的是:RewriteRule^/po$[R=301,L]我不知道为什么它现在工作,而不是以前,可能Apache没有正确地重新启动?我不确定该行在vhost conf文件中的什么位置。我试着把它放在“引擎打开”下,但没用。感谢当我在“RewriteEngine On”下添加这一行并重新启动Apache时,它给了我一个错误RewriteOptions:未知选项“AllowNoSlash”。好消息是我现在不用它就可以工作了。我使用的是:RewriteRule^/po$[R=301,L]我不知道为什么它现在工作而不是以前,也许Apache没有正确重启?
RewriteRule ^/po$ http://new.example.com/po/index_mat.php [R=301,L]
RewriteOptions AllowNoSlash
RewriteRule ^/po$ http://new.example.com/po/index_mat.php [R=301,L]