Are the .htaccess rewrite rules causing my query string to be empty?












1















Here's my problem:




  • I'm sending a query string called 'sort' through $_GET to a PHP script

  • The script recognizes the query and I can use it

  • 5 seconds later I call the same PHP function, but the query is empty

  • Also I mention that the query is visible at all time on the URL &sort=new so I can see it there I just can't use it except the first time

  • Also I've tried parsing the URL and garbing the query directly but it's also empty

  • I need it to work as it should and be able to use the string as many times as I call the PHP script


Because I'm using some rewrite rules my URL looks like this (no .php which I'm guessing might be the problem)



example.com/group/groupName?&sort=new


Below are all the .htaccess rewrite rules used and I think they might causing the issue



RewriteRule ^group/?$                                       index.php?a=group                           [NC]
RewriteRule ^group/([^/]+)/?$ index.php?a=group&name=$1 [QSA]
RewriteRule ^group/deleted/([^/]+)/?$ index.php?a=group&deleted=$1 [NC]
RewriteRule ^group/([^/]+)/([^/]+)/?$ index.php?a=group&name=$1&r=$2 [NC]
RewriteRule ^group/([^/]+)/search/([^/]+)/?$ index.php?a=group&name=$1&search=$2 [NC]
RewriteRule ^group/([^/]+)/friends/([^/]+)/?$ index.php?a=group&name=$1&friends=$2 [NC]


All these ReWrite rules are used on the site but I can't figure out if it's them that are causing the problem or it's something on the PHP code.



Edit:
I'm using in htaccess



RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]


This is how I"m trying to get it with PHP:



$parts = parse_url($_SERVER["REQUEST_URI"]);
parse_str($parts['query'], $query);
$sortBy = $query['sort'];









share|improve this question




















  • 1





    "my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

    – Jeff
    Nov 22 '18 at 21:14













  • What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

    – CsgoTalks Com
    Nov 22 '18 at 21:17













  • But how do you know how your URL looks?

    – Jeff
    Nov 22 '18 at 21:30











  • sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

    – Jeff
    Nov 22 '18 at 21:31











  • I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

    – CsgoTalks Com
    Nov 22 '18 at 21:32
















1















Here's my problem:




  • I'm sending a query string called 'sort' through $_GET to a PHP script

  • The script recognizes the query and I can use it

  • 5 seconds later I call the same PHP function, but the query is empty

  • Also I mention that the query is visible at all time on the URL &sort=new so I can see it there I just can't use it except the first time

  • Also I've tried parsing the URL and garbing the query directly but it's also empty

  • I need it to work as it should and be able to use the string as many times as I call the PHP script


Because I'm using some rewrite rules my URL looks like this (no .php which I'm guessing might be the problem)



example.com/group/groupName?&sort=new


Below are all the .htaccess rewrite rules used and I think they might causing the issue



RewriteRule ^group/?$                                       index.php?a=group                           [NC]
RewriteRule ^group/([^/]+)/?$ index.php?a=group&name=$1 [QSA]
RewriteRule ^group/deleted/([^/]+)/?$ index.php?a=group&deleted=$1 [NC]
RewriteRule ^group/([^/]+)/([^/]+)/?$ index.php?a=group&name=$1&r=$2 [NC]
RewriteRule ^group/([^/]+)/search/([^/]+)/?$ index.php?a=group&name=$1&search=$2 [NC]
RewriteRule ^group/([^/]+)/friends/([^/]+)/?$ index.php?a=group&name=$1&friends=$2 [NC]


All these ReWrite rules are used on the site but I can't figure out if it's them that are causing the problem or it's something on the PHP code.



Edit:
I'm using in htaccess



RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]


This is how I"m trying to get it with PHP:



$parts = parse_url($_SERVER["REQUEST_URI"]);
parse_str($parts['query'], $query);
$sortBy = $query['sort'];









share|improve this question




















  • 1





    "my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

    – Jeff
    Nov 22 '18 at 21:14













  • What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

    – CsgoTalks Com
    Nov 22 '18 at 21:17













  • But how do you know how your URL looks?

    – Jeff
    Nov 22 '18 at 21:30











  • sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

    – Jeff
    Nov 22 '18 at 21:31











  • I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

    – CsgoTalks Com
    Nov 22 '18 at 21:32














1












1








1








Here's my problem:




  • I'm sending a query string called 'sort' through $_GET to a PHP script

  • The script recognizes the query and I can use it

  • 5 seconds later I call the same PHP function, but the query is empty

  • Also I mention that the query is visible at all time on the URL &sort=new so I can see it there I just can't use it except the first time

  • Also I've tried parsing the URL and garbing the query directly but it's also empty

  • I need it to work as it should and be able to use the string as many times as I call the PHP script


Because I'm using some rewrite rules my URL looks like this (no .php which I'm guessing might be the problem)



example.com/group/groupName?&sort=new


Below are all the .htaccess rewrite rules used and I think they might causing the issue



RewriteRule ^group/?$                                       index.php?a=group                           [NC]
RewriteRule ^group/([^/]+)/?$ index.php?a=group&name=$1 [QSA]
RewriteRule ^group/deleted/([^/]+)/?$ index.php?a=group&deleted=$1 [NC]
RewriteRule ^group/([^/]+)/([^/]+)/?$ index.php?a=group&name=$1&r=$2 [NC]
RewriteRule ^group/([^/]+)/search/([^/]+)/?$ index.php?a=group&name=$1&search=$2 [NC]
RewriteRule ^group/([^/]+)/friends/([^/]+)/?$ index.php?a=group&name=$1&friends=$2 [NC]


All these ReWrite rules are used on the site but I can't figure out if it's them that are causing the problem or it's something on the PHP code.



Edit:
I'm using in htaccess



RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]


This is how I"m trying to get it with PHP:



$parts = parse_url($_SERVER["REQUEST_URI"]);
parse_str($parts['query'], $query);
$sortBy = $query['sort'];









share|improve this question
















Here's my problem:




  • I'm sending a query string called 'sort' through $_GET to a PHP script

  • The script recognizes the query and I can use it

  • 5 seconds later I call the same PHP function, but the query is empty

  • Also I mention that the query is visible at all time on the URL &sort=new so I can see it there I just can't use it except the first time

  • Also I've tried parsing the URL and garbing the query directly but it's also empty

  • I need it to work as it should and be able to use the string as many times as I call the PHP script


Because I'm using some rewrite rules my URL looks like this (no .php which I'm guessing might be the problem)



example.com/group/groupName?&sort=new


Below are all the .htaccess rewrite rules used and I think they might causing the issue



RewriteRule ^group/?$                                       index.php?a=group                           [NC]
RewriteRule ^group/([^/]+)/?$ index.php?a=group&name=$1 [QSA]
RewriteRule ^group/deleted/([^/]+)/?$ index.php?a=group&deleted=$1 [NC]
RewriteRule ^group/([^/]+)/([^/]+)/?$ index.php?a=group&name=$1&r=$2 [NC]
RewriteRule ^group/([^/]+)/search/([^/]+)/?$ index.php?a=group&name=$1&search=$2 [NC]
RewriteRule ^group/([^/]+)/friends/([^/]+)/?$ index.php?a=group&name=$1&friends=$2 [NC]


All these ReWrite rules are used on the site but I can't figure out if it's them that are causing the problem or it's something on the PHP code.



Edit:
I'm using in htaccess



RewriteRule ^ https://www.%1%{REQUEST_URI} [NE,L,R]


This is how I"m trying to get it with PHP:



$parts = parse_url($_SERVER["REQUEST_URI"]);
parse_str($parts['query'], $query);
$sortBy = $query['sort'];






php html .htaccess






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 21:52







CsgoTalks Com

















asked Nov 22 '18 at 21:13









CsgoTalks ComCsgoTalks Com

3017




3017








  • 1





    "my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

    – Jeff
    Nov 22 '18 at 21:14













  • What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

    – CsgoTalks Com
    Nov 22 '18 at 21:17













  • But how do you know how your URL looks?

    – Jeff
    Nov 22 '18 at 21:30











  • sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

    – Jeff
    Nov 22 '18 at 21:31











  • I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

    – CsgoTalks Com
    Nov 22 '18 at 21:32














  • 1





    "my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

    – Jeff
    Nov 22 '18 at 21:14













  • What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

    – CsgoTalks Com
    Nov 22 '18 at 21:17













  • But how do you know how your URL looks?

    – Jeff
    Nov 22 '18 at 21:30











  • sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

    – Jeff
    Nov 22 '18 at 21:31











  • I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

    – CsgoTalks Com
    Nov 22 '18 at 21:32








1




1





"my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

– Jeff
Nov 22 '18 at 21:14







"my URL looks like this" - how do you mean that? Your URL looks the way you type it into the address bar or as a link looks like. So the question for me is how you are "sending a query string"

– Jeff
Nov 22 '18 at 21:14















What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

– CsgoTalks Com
Nov 22 '18 at 21:17







What I meant is - that's how my URL should be looking without any rewrite rules. I'm submitting a form with a 'sort' text input.

– CsgoTalks Com
Nov 22 '18 at 21:17















But how do you know how your URL looks?

– Jeff
Nov 22 '18 at 21:30





But how do you know how your URL looks?

– Jeff
Nov 22 '18 at 21:30













sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

– Jeff
Nov 22 '18 at 21:31





sidenote: It would be much easier to handle if you'd send everything after ^group/ to index.php as a parameter and do the rest of routing there.

– Jeff
Nov 22 '18 at 21:31













I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

– CsgoTalks Com
Nov 22 '18 at 21:32





I've removed the first part because I guess it confuses everything. The URL above is what I see on the search bar.

– CsgoTalks Com
Nov 22 '18 at 21:32












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438044%2fare-the-htaccess-rewrite-rules-causing-my-query-string-to-be-empty%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53438044%2fare-the-htaccess-rewrite-rules-causing-my-query-string-to-be-empty%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out