每服务器重写不起作用

时间:2012-05-22 14:21:11

标签: apache .htaccess mod-rewrite

我在/etc/apache2/openpanel.d/www.example.com.conf中有一个VirtualHost指令:

<VirtualHost *:80>
   ServerAdmin        "jon@example.com"
   DocumentRoot       /home/openpanel-admin/sites/www.example.com/public_html
   ServerName         www.example.com
   ServerAlias        example.com
   <Directory /home/openpanel-admin/sites/www.example.com/public_html>
   AllowOverride      All
   Allow from all
   </Directory>
   Include /etc/apache2/openpanel.d//www.example.com.inc/[^.#]*
   Include /etc/apache2/openpanel.d//global.inc
</VirtualHost>

我在/etc/apache2/openpanel.d/www.example.com.inc/RewriteRules

中有以下内容
<Directory /home/openpanel-admin/sites/www.stallfinder.com/public_html>
        Options +FollowSymlinks
        RewriteEngine On

        RewriteRule agricultural-show-c780.html /search/event/agricultural-shows/1/ [R=301,L]
        RewriteRule antique-fair-c596.html /search/event/antique-and-collectors-fairs/1/ [R=301,L]
        RewriteRule baby-and-toddler-fairs-c896.html /search/event/baby-and-toddler-fairs/1/ [R=301,L]
        RewriteRule book-fair-c631.html /search/event/book-fairs/1/ [R=301,L]

        # etc... there are ~3000 of these
</Directory>

我在.htaccess中有/home/openpanel-admin/sites/www.example.com/public_html个文件:

Options +FollowSymlinks

RewriteEngine On
RewriteBase /

# Search pages
RewriteRule ^search/(stallholder|event)/?$ /find-$1.php [L]
RewriteRule ^search/(stallholder|event)/([^/]+)/([0-9]+)/? /$1.php?name=$2&id=$3 [L]

但是包含文件(RewriteRules)中的RewriteRules似乎没有被解析/使用。

该文件正在被包含,因为我可以将非允许的东西放在那里,apache将无法加载配置文件,但是如果我打开Apache重定向日志记录,那么我只看到[perdir]行,就好像所有的RewriteRules一样我进入了RewriteRules包含没有被处理。

global.inc文件为空,我.htaccess文件中的RewriteRules运行正常。

有什么迹象表明我做错了什么?

1 个答案:

答案 0 :(得分:1)

尝试将RewriteOptions指令添加到.htaccess中,以允许在父(上)级别执行重写规则。

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions