-1

This is the htaccess I have setup for my MVC.

  <IfModule mod_rewrite.c>
        RewriteEngine On  
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
    </IfModule>

So any request to localhost/users/ will redirect to localhost?url=users/

But when there are some get data available in the url for example: localhost/users/?msg=hello

I'm missing the ?msg=hello in the $_GET['url']. Is it possible to redirect to something like localhost/users/msg=hello/

Praveen
  • 2,400
  • 3
  • 23
  • 30

2 Answers2

4

Use "QueryString Append" option,

RewriteRule ^(.*)$ index.php?route=/$1 [QSA,L]

Referred from :.htaccess: GET variables are lost in rewrite

Community
  • 1
  • 1
Vishal Santharam
  • 1,963
  • 1
  • 16
  • 30
0

What you're trying to do would be pretty complicated. As an alternative you could try the following:

RewriteRule ^(.*)$ index.php/$1 [PT,L]

When using that Rule you can access the URL via $_SERVER['REQUEST_URI'].

The Reason you're loosing the get parameters is because the server creates the URL with two '?'. Ex:

http://localhost/?url=users/?msg=123
Dragony
  • 1,712
  • 11
  • 20