0

我试图让 htaccess 重写这个 url:

http://127.0.0.1/papercut3/article/post-title/

对此:

http://127.0.0.1/papercut3/article.php?p=post-title/

我当前的 .htaccess 是:

Options +FollowSymLinks  
RewriteEngine On  

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^article/(\d+)*$ ./article.php?p=$1  
RewriteRule ^section/(\d+)*$ ./section.php?s=$1  

我的网址写在代码中:

http://127.0.0.1/papercut3/article/execution-call-for-cinema-killer/

我的问题是,当我单击链接时,我得到了这个:

Not Found

The requested URL /papercut3/article/syria-suffers-deadliest-month/ was not found on this server.

我正在使用 WAMP,.htaccess 位于 /papercut3 目录的根目录中,其中包含所有核心文件。任何帮助将不胜感激!:)

4

2 回答 2

1

如果你可以使用.htaccess文件,你希望它看起来像:

Options +FollowSymLinks  
RewriteEngine On  

RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  

RewriteRule ^article/(.+)$ ./article.php?p=$1  
RewriteRule ^section/(.+)$ ./section.php?s=$1  

或者,您可以更具体地了解允许的内容,但您问题中的那个只允许 character [0-9],这样它就会打开它,让相应的 PHP 文件进行检查/错误处理。

于 2013-04-02T10:48:44.420 回答
0

您可能会在 apache 的日志文件中找到帮助,但我认为这与AllowOverride指令有关,必须设置为 None。

如文档中所述,您AllowOverride至少需要包含FileInfo.

编辑:顺便说一句,您的规则与您的任何网址都不匹配,因为您期望一个 int\d但不提供任何输入。

于 2013-04-02T10:42:17.323 回答