以下为:URL重写配置 
RewriteEngine On
RewriteBase /
RewriteRule ^index/(.*)\.html$ index.php?page=$1 [L]
以下为PHP文件代码:
<?php
echo "伪静态测试获取的参数值是:". $_GET["page"];
?>
===========================
http://localhost/index.php?page=999  没问题一切正常
但是这样的话http://localhost/index/999.html  页面运行正常就是这个值获取不到呀。
这是怎么样回事,给高分请高手们帮忙回答一下,刚开始研究PHPURL重写,在网上也找了这样简单的例子 也没有看出是哪的问题呀。  

解决方案 »

  1.   

    RewriteRule ^index/([0-9]+)\.html$ /index.php?page=$1 [L]
      

  2.   

    RewriteRule ^index/(.*)\.html$ index.php?page=$1 [L] 
    改为:
    RewriteRule  index\/(\d+)\.html$ index.php?page=$1
    然后再试一下,应该可以获取$_GET["page"]这个值的!
      

  3.   

    如果不是最后一条规则就要把[L]去掉,碰到[L]就不继续解析了,一般的,如果不是301我都不加L
      

  4.   

    难道是跟 apache设置 有关系吗?
      

  5.   

    请先确认 URLRewrite 功能已开启
      

  6.   

    规则没有问题
    页面运行正常是什么意思????除了后面的$_GET['page']值,别的都打印了?
      

  7.   

    是的  除了后面的$_GET['page']值 没有,其它的都输出了
      

  8.   

    你这个是因为/index/2.html找不到时会去定位/index定位这个目录然后 你的apache配置有index.php那么其实正好找到就是index.php而没有通过重写转换
      

  9.   

    是 URL重写的规则有问题吗还是 运行环境配置的问题,查看了一下apache的运行日志
    previous Apache run?
    [Wed Apr 27 21:17:11 2011] [notice] Apache/2.2.9 (APMServ) PHP/5.2.6 configured -- resuming normal operations
    [Wed Apr 27 21:17:11 2011] [notice] Server built: Jun 13 2008 04:04:59
    [Wed Apr 27 21:17:11 2011] [notice] Parent: Created child process 2020
    [Wed Apr 27 21:17:12 2011] [notice] Child 2020: Child process is running
    [Wed Apr 27 21:17:12 2011] [notice] Child 2020: Acquired the start mutex.
    [Wed Apr 27 21:17:12 2011] [notice] Child 2020: Starting 500 worker threads.
    [Wed Apr 27 21:17:12 2011] [notice] Child 2020: Starting thread to listen on port 80.
    [Wed Apr 27 23:44:29 2011] [error] [client 192.168.1.200] File does not exist: E:/website/APMServ5.2.6/www/htdocs/favicon.ico
    [Wed Apr 27 23:45:39 2011] [error] [client 192.168.1.200] File does not exist: E:/website/APMServ5.2.6/www/htdocs/11.html
    我测试输入的地址就是  index/11.html   这个日志里也确实指出了  文件不存。
      

  10.   

    当 URL重定向规则写成这样的就正常了   
    RewriteRule ([a-zA-Z0-9]{1,}).html$ index.php?page=$1求解呀!!
      

  11.   


    当你rewrite写成RewriteRule ^index([^\.]+)\.html$ /index.php?page=$1 [L]你就知道为什么了