Apache Mod_ReWrite突然停止工作

时间:2011-07-06 02:03:50

标签: apache mod-rewrite

我在服务器上设置了mod_rewrite来重写一个类似下面的URL

http://www.example.com/1

http://www.example.com/index.php?show=1

用词来缩短网址。当系统在我的开发网站上的子域下运行时,一切正常,但现在它只会生成Not Found错误,但如果我手动输入网址/index.php?show=1,它可以正常工作。

所以唯一的变化是从

切换的网址

http://www.site.example.com

http://www.site.com

然而,它仍然在服务器上的public_html内的同一服务器和同一子文件夹上运行,只是新域名已被指向该文件夹。

它存储的文件夹是/public_html/paste

目录中运行的完整.htaccess文件是

# Set Default File
DirectoryIndex index.php

# Turn ReWrite Engine On
RewriteEngine on

# Create Rule To Write URLs To Shorter Versions
RewriteRule /([a-z0-9]+) /index.php?show=$1

我无法启用RewriteLog,因为托管由于某种原因不允许它。

2 个答案:

答案 0 :(得分:2)

听起来没有为该文件夹正确设置AllowOverride指令。在Apache配置中,您应确保用于主域的目录或Vhost的AllowOverride设置为All

http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride

答案 1 :(得分:1)

您可能需要指定RewriteBase指令。

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

我还会注意到Options +FollowSymlinks在那里也很好,以防你在配置链中进一步关闭它(如果没有它,重写就不会工作)。

相关问题