V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
xmbaozi
V2EX  ›  问与答

求助!php伪静态,我错在哪儿啊

  •  
  •   xmbaozi · 2011-05-25 23:43:20 +08:00 · 5332 次点击
    这是一个创建于 4719 天前的主题,其中的信息可能已经有所发展或是发生改变。
    http://abc.com/show-htm-id-18704025.html
    http://abc.com/show.php?id=18707619
    写成上面的伪静态!


    000webhost的linux php主机


    RewriteRule ^show-htm-id-([0-9]+)\.html$ show\.php\?=$1

    哪里不对啊?
    16 条回复    1970-01-01 08:00:00 +08:00
    xmbaozi
        1
    xmbaozi  
    OP
       2011-05-25 23:45:20 +08:00
    对你们很简单的。网上找了很多,头皮都抓破了
    Hyperion
        2
    Hyperion  
       2011-05-25 23:57:16 +08:00
    额,正则里问号不用转义。
    yesmeck
        3
    yesmeck  
       2011-05-25 23:57:24 +08:00
    RewriteRule ^show-htm-id-([0-9]+)\.html$ show.php?id=$1

    后面的不是正则,不需要转义
    Hyperion
        4
    Hyperion  
       2011-05-25 23:59:40 +08:00
    “show\.php\?=$1 ”汗,id呢?
    Hyperion
        5
    Hyperion  
       2011-05-26 00:03:37 +08:00
    = =+ 抱歉 我表述概念上有错 误导了...
    xmbaozi
        6
    xmbaozi  
    OP
       2011-05-26 00:14:56 +08:00
    @yesmeck @Hyperion 给个可用的,我折腾一个晚上了
    ray58750034
        7
    ray58750034  
       2011-05-26 00:32:04 +08:00
    RewriteRule ^show-htm-id-([0-9]+)\.html$ show.php?id=$1
    去掉转义可以用么
    Hyperion
        8
    Hyperion  
       2011-05-26 00:38:19 +08:00
    RewriteEngine On
    RewriteRule ^/show-htm-id-([0-9]+)\.html$ /show.php?id=$1

    完整的话...
    glume
        9
    glume  
       2011-05-26 00:58:35 +08:00
    .htaccess伪静态是不是特别费资源?
    predator
        10
    predator  
       2011-05-26 06:58:33 +08:00 via Android
    @glume
    虚拟主机一般只有这个办法
    xmbaozi
        11
    xmbaozi  
    OP
       2011-05-27 22:54:08 +08:00
    @Hyperion @ray58750034 都试了还是不行

    主机是支持.htaccess,可以用ErrorDocument 404 /404.jpg自定义404
    是因为主机环境吗?给出了phpinfo(),求高手看看
    http://58days.com/fm/info.php
    Platinum
        12
    Platinum  
       2011-05-27 23:28:45 +08:00
    这类问题一般看 web server 的 error log 就能找到答案
    Hyperion
        13
    Hyperion  
       2011-05-27 23:54:07 +08:00
    汗, 别是apache没有mod_rewrite吧……这么写

    RewriteEngine on
    RewriteRule .* http://www.google.com

    看看能不能跳转到google,能就是支持,你写法上有问题;不能的话……
    xmbaozi
        14
    xmbaozi  
    OP
       2011-05-28 14:46:28 +08:00
    @Hyperion 搞定了!

    RewriteEngine On
    RewriteBase /
    RewriteRule ^/show-htm-id-([0-9]+)\.html$ /show.php?id=$1
    Hyperion
        15
    Hyperion  
       2011-05-28 15:11:47 +08:00
    汗...为什么要先RewriteBase...多级的目录么?
    xmbaozi
        16
    xmbaozi  
    OP
       2011-05-28 17:16:04 +08:00
    不懂...
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3189 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 10:48 · PVG 18:48 · LAX 03:48 · JFK 06:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.