phpurlgetget-method

GET method in php clean URL


I have successfully created clean url for my project.. now what i need to do is add variables to URL..

localhost/user1/file?action=add
localhost/user2/file2?action=delete

where user and file are already rewritten i dont want it to be like localhost/user/file/add because localhost/user/folder/file will be mistaken to to the action parameter.. please help


Solution

  • Try using the ampersand instead of question mark:

    localhost/user2/file2&action=delete
    

    In your htaccess, the rewrite rule might look something like this:

    RewriteRule ^user([0-9]+)/file([0-9]+)$ /page\.php?user=$1&file=$2
    

    As you can see, the question mark is already there even though it is masked in the address bar. Appending another variable to the query string would require the ampersand for successful concatenation.