php - Removing question mark from query string -


my goal: rewrite url host.com/?abc host.com/abc , able request via $_server['query_string']. found following rules:

rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /?$1 [l,qsa] 

but whatever reason, $_server['query_string'] empty, unless put '?' in front of query string. when print_r( $_server ) or print_r( $_get ), query string not present anywhere. suggestions i'm doing wrong? thanks!

update; i'm using nginx 'front' proxy , redirect requests apache using following rule:

 server  {   listen   80;    root /var/hosts/hostcom;   index index.php index.html index.htm;    server_name host.com;    location / {     try_files $uri $uri/ /index.php;   }    location ~ \.php$ {            proxy_set_header x-real-ip        $remote_addr;           proxy_set_header x-forwarded-for  $remote_addr;           proxy_set_header host $host;           proxy_pass http://127.0.0.1:8010;     }     location ~ /\.ht {           deny all;   }  } 

if request apache port directly, works host.com:8010/?abc, not through nginx, suggestions? thanks!

from nginx docs:

if none of files found, internal redirect uri specified in last parameter made.

the try_files rewrites request nonexistent file index.php, losing path before ever reaches apache.

i believe location blocks should more this, should forward request missing file apache without rewriting it:

  location / {     try_files $uri $uri/ @apache;   }    location @apache {           proxy_set_header x-real-ip        $remote_addr;           proxy_set_header x-forwarded-for  $remote_addr;           proxy_set_header host $host;           proxy_pass http://127.0.0.1:8010;    } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -