Apache中的URL重写不适合我

时间:2012-04-10 09:00:48

标签: php apache url-rewriting

我正在使用WAMP并在'http:// localhost / snap2 / html'文件夹中创建了一个网站。我正在尝试执行以下重写规则,但这对我不起作用。

服务器在下面给出了一个错误:

在此服务器上找不到请求的网址/snap2/html/browsed.html。

我的.htaccess文件位于html文件夹中,其结构如下:

`RewriteEngine On

RewriteRule ^ decision /([0-9] +)$ /snap2/html/decision.php?PanelID = $ 1`

网站的结构类似于'www / snap2 / html

事实上,我正在尝试重写以下网址

http://localhost/snap2/html/decision.php?PanelID=20

进入

http://localhost/snap2/html/decision/20

此外,Options + FollowSymLinks给出了错误500,因此我对此进行了评论。

非常感谢任何帮助。

3 个答案:

答案 0 :(得分:0)

你写两次RewriteRule。尝试

RewriteRule decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1 [L, QSA]

RewriteRule snap2/html/decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1 [L, QSA]

答案 1 :(得分:0)

试试这个:

RewriteEngine On

RewriteRule RewriteRule ^snap2/html/decision/([0-9]+)$ /snap2/html/decision.php?PanelID=$1

但我猜这不是你想要的。但也许你会看到你错在哪里。

答案 2 :(得分:0)

正则表达式中的符号^表示后面的字符串应位于URL的开头。因此您必须包含整个路径,有关更多示例,请参阅htaccess RewriteEngine