【问题标题】:Rewrite php page with htaccess用 htaccess 重写 php 页面
【发布时间】:2014-01-17 19:37:15
【问题描述】:

我正在 poll.php?code=STRINGHERE 创建一个表单

我想用 .htaccess 重写它来做 WEBSITE.com/STRINGHERE 我以前做过,但不记得我需要在 .htaccess 中做什么,比如

RewriteEngine On
RewiteRule ^(\w.+)$ ./poll.php?code=$1

虽然我可能错了。任何帮助都会很棒。

【问题讨论】:

    标签: php .htaccess ftp rewrite


    【解决方案1】:

    试试:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewiteRule ^([^/]+)$ ./poll.php?code=$1 [L,QSA]
    

    如果您需要在直接向 poll.php 发出请求时重定向浏览器:

    RewriteCond %{THE_REQUEST} \ /+poll\.php\?code=([^&\ ]+)
    RewriteRule ^ /%1? [L,R]
    

    【讨论】:

    • 嘿乔恩,所以我不会撒谎我忘了我问过这个问题,但你的答案是正确的。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 2013-01-17
    • 2023-03-04
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    相关资源
    最近更新 更多