0

我只是希望 feature.php?id=1 更改为 feature/1

mod_rewrite 根据 php 启用。我尝试将垃圾放入 .htaccess 文件中,这给了我一个 500 错误,所以我猜那也可以。

我的虚拟主机文件

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "C:/htdocs"
  ServerName test2
  DirectoryIndex index.php

  <Directory "C:/htdocs">
    AllowOverride All
    Allow from All
  </Directory>
  RewriteLog "C:/xampp/apache/logs/rewrite.log"
  RewriteLogLevel 9
</VirtualHost>

我的.htaccess文件的内容

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
RewriteEngine On  
RewriteRule ^/?feature/([a-zA-Z0-9]+)$ /feature.php?id=$1 [L,QSA]
</IfModule>

以及rewrite.log的内容

127.0.0.1 - - [19/Oct/2012:12:23:17 +0100] [test2/sid#2006540​​][rid#66156b0/initial] (3) [perdir C:/htdocs/] 剥离每个目录前缀: C:/htdocs/feature.php -> feature.php
127.0.0.1 - - [19/Oct/2012:12:23:17 +0100] [test2/sid#2006540​​][rid#66156b0/initial] (3 ) [perdir C:/htdocs/] 将模式 '^/?feature/([a-zA-Z0-9]+)$' 应用于 uri 'feature.php'
127.0.0.1 - - [2012 年 10 月 19 日: 12:23:17 +0100] [test2/sid#2006540​​][rid#66156b0/initial] (1) [perdir C:/htdocs/] 通过 C:/htdocs/feature.php

4

1 回答 1

0

Riiiiiight.

I expected the links to re-write themselves. so basically, if I wanted the link to go to feature/1 I should have made it that. feature.php?id=1 link would not magically change to feature/1 and link to feature/1.

Well, you learn something every day.

于 2012-10-19T12:04:56.920 回答