简体   繁体   English

用htaccess重写php页面

[英]Rewrite php page with htaccess

I am creating a form at poll.php?code=STRINGHERE 我正在poll.php?code = STRINGHERE创建一个表单

I want to rewrite it with .htaccess to do WEBSITE.com/STRINGHERE I have done it before but don't remember what I need to do in the .htaccess its something like 我想用.htaccess重写它来做WEBSITE.com/STRINGHERE我以前做过,但是不记得我需要在.htaccess中做什么,就像

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

Although I might be wrong. 虽然我可能是错的。 Any help would be great. 任何帮助都会很棒。

Try: 尝试:

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

And if you need to redirect the browser when requests are made directly to poll.php: 并且如果在直接向poll.php发出请求时需要重定向浏览器:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM