dongmi1941 2012-03-09 11:19
浏览 20
已采纳

在urlrewrite之后,php得不到值

I want to url rewrite from page.php?search=keywords to page/keywords

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]    
RewriteRule ^page/(.*)/?$ page.php?search=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
</IfModule>

Then type some url like: localhost/page/hello, I can not get hello

<?php
echo $_SERVER['QUERY_STRING'];//search=
echo $_GET['search'];//empty
?>
  • 写回答

1条回答 默认 最新

  • dongqian9013 2012-03-09 11:24
    关注

    The "hello" part of the url should be $1, not $2 - you're only extracting one part of the url with that regex. Try:

    RewriteRule ^page/(.*)/?$ page.php?search=$1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退