【发布时间】:2014-01-17 19:37:15
【问题描述】:
我正在 poll.php?code=STRINGHERE 创建一个表单
我想用 .htaccess 重写它来做 WEBSITE.com/STRINGHERE 我以前做过,但不记得我需要在 .htaccess 中做什么,比如
RewriteEngine On
RewiteRule ^(\w.+)$ ./poll.php?code=$1
虽然我可能错了。任何帮助都会很棒。
【问题讨论】:
我正在 poll.php?code=STRINGHERE 创建一个表单
我想用 .htaccess 重写它来做 WEBSITE.com/STRINGHERE 我以前做过,但不记得我需要在 .htaccess 中做什么,比如
RewriteEngine On
RewiteRule ^(\w.+)$ ./poll.php?code=$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]
【讨论】: