【问题标题】:RewriteRule not working, mod_rewrite enabledRewriteRule 不起作用,启用了 mod_rewrite
【发布时间】:2012-10-10 00:23:05
【问题描述】:

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

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

我的 vhosts 文件

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/] 剥离-dir 前缀: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 - - [19/Oct/2012:12:23:17 +0100] [test2/sid#2006540​​][rid#66156b0/initial] (1) [perdir C:/htdocs/] 通过 C:/ htdocs/feature.php

【问题讨论】:

  • 请注意,stackoverflow 已经从我的 vhosts 文件中删除了一些内容

标签: mod-rewrite


【解决方案1】:

Riiiiight。

我希望链接会自己重写。所以基本上,如果我想让链接转到 feature/1,我应该做到这一点。 feature.php?id=1 链接不会神奇地更改为 feature/1 并链接到 feature/1。

嗯,你每天都会学到一些东西。

【讨论】:

    猜你喜欢
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-10
    • 1970-01-01
    相关资源
    最近更新 更多