apache - Match Question Mark in mod_rewrite rule regex -


I want to rewrite the URL with many substrings. A substring is being requested as a subdirectory, while any other is requested as normal query string parameters. For example, I would like to rewrite the URL from

  http: /. /www.mysite.com/mark/friends?page=2  

to

  http://www.mysite.com/friends.php? User = Icon and Page = 2  

I'm able to complete it with the exception of question mark character. Here is my rewrite rule:

  ... revival on rebatebase / revised rule ^ ([A-Za-z0-9 -_] +) / friends [?]? ([^ / \.] +)? $ Friends.php? Users = $ 1 and $ 2 [L]  

If I change the question mark to another character then it works great. I think the problem is that '?' The character is being misinterpreted as the beginning of a new query string.

I have to pass any such parameter, as is in the form of / users / friends. How do I do this?

You should use the [QSA] to rewrite the question string Instead of trying to flag the flag. [QSA] passes on the written URL again on the query string.

Then your rule should look like this:

  ... revival on revivebase / rewrite rule ^ ([A-Za-z0-9 -_] +) / friends /? Friends.php? User = $ 1 [QSA, L]  

Your case is very similar.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -