【问题标题】:htaccess redirection with variables带变量的 htaccess 重定向
【发布时间】:2011-07-14 03:18:58
【问题描述】:

有人可以帮我解决这个问题吗?我想做的是重定向-

http://www.domain.com/testpage 

http://www.domain.com/index.php?id=testpage

如果该页面在服务器上不存在。

【问题讨论】:

    标签: php .htaccess


    【解决方案1】:

    使用 .htaccess 和 RewriteRule

    # -f means "is it a file" !-f "not(is it a file)"
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /index.php?/id=$1 [L]
    # RewriteRule takes a regular expression and an output followed by
    # a set of instructions in the brackets.
    # in this case, we're saying, 'take anything not found and add it to index.php?id=
    # [L] means that this should be considered a final instruction -- no more rules
    # should apply here.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      • 2019-08-20
      相关资源
      最近更新 更多