php - mod_rewrite: no ? and # in REQUEST_URI -


What am I trying to do: format is the "beautiful url", which is a PHP script (index. Php) by looking at the REQUEST_URI server variable.
In my example, there will be REQUEST_URI '/ one / two / three' (BTW. Is this a good idea in general?)

I use Apache's mod_uite to get it I am here.
Here is the rewrite that I use in my .htaccess:

 RewriteRule ^ /? ([A-zA-Z /] +) /? $ /index.php [NC, L] 

This really works well so far; It makes every REQUEST_URI forward in which A-Z, A-Z or '/' to / indix.fp, where it is processed.

Only fault: '?' (Question mark) and '#' (hash keys) can still be allowed in REQUEST_URI, maybe even more characters that I still like to search for.
To restrict them through .htaccess and an adequate additional

thanks

piece identifier, e.g. # Some-anchors are controlled by the browser, not the server. Javascript will need to redirect it and delete it, although I'm not sure why you want to do this.

[Criticism after explanation] Only rewrite the query string when it is empty:

rewrite% {QUERY_STRING} ^ $ RewriteRule ^ /? ([A-zA-Z /] +) /? $ / Endex.php [NC, L]

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -