Apache: RewriteRule removing trailing dot
Here is my .htaccess rules:
RewriteEngine On
Re开发者_Go百科writeCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)/(.*)$ index.php?var1=$1&item=$2&var2=%{REQUEST_URI} [NC,L]
RewriteRule ^(.*)$ index.php?var1=$1 [NC]
Here is an url (with trailing dot in the end):
http://localhost/test/secondvar.
The problem is that the trailing dot is not coming inside the var2
GET
variable
I used a print_r($_GET)
and here is the result with the above url:
Array ( [var1] => test [var2] => secondvar [uri] => /test/secondvar. )
So my question is, how do I get that trailing dot from the URL as a parameter to the var? As you can see, the REQUEST_URI
is showing that the apache knows of the dot.
I know I can not send the paths as GET
parameters and take care to read the paths in the URI from PHP, but I would like to know why the dot isn't coming and how to fix it, if too complicated I rather go for the direct PHP solution.
EDIT: Is not only trailing dot but trailing ? too... =[
It might just be that php excludes trailing dots. I know that they often convert dot's in POST/GET to underscores. I would just do
explode('/',$_SERVER['REQUEST_URI'])
精彩评论