Pregunta

I am creating a form at 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

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

Although I might be wrong. Any help would be great.

¿Fue útil?

Solución

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:

RewriteCond %{THE_REQUEST} \ /+poll\.php\?code=([^&\ ]+)
RewriteRule ^ /%1? [L,R]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top