1
How are you?
I am doing the user profile and there are 3 tabs, IE, three areas that users can navigate. For profile, I rewrote as follows on . htaccess:
RewriteRule ^profile/([0-9]+)/([a-z0-9-]+)/?$ profile.php?id=$1&name=$2 [NC]
This is not the problem, the problem is that I want to pass GET variables the normal way too, as in the example of tabs, getting something like URL:
profile/245/user-name?tab=about
But it doesn’t read the variable when I put it to test:
echo $_GET['tab'];
Returns the following error:
Notice: Undefined index: tab in C:...\profile.php on line 14
NOTE: In the pages that I rewrite that DO NOT HAVE VARIABLES, it reads normally! I could even include in the . htaccess this variable this way, but imagine you have several of these for little things, like ? Edit=1...
It didn’t work... I’ve thought about doing this (adding a third variable, but it’s not very effective I think). As the application end up 'confusing', I was confused haha. How so? In my case, I always validate the URL, I link the user’s name (with a function that transforms this: José Rodrigues, in this, Jose-Rodrigues). I’ve never had a problem with that, but I was worried, could you give me an example? And as for this other method, I think I’ve seen some people using it, so if you could send some referral links, I’d be grateful...
– Artur
If it didn’t work, you need to review the code, I even put a demo in Regexr for you to test "live", with a test URL and everything. As for "effectiveness", one or ten variables will not change the situation. The work of the regex is practically the same in all cases.
– Bacco
Change the data in the link above, and see how it is rewritten in the bottom panel: http://www.regexr.com/3dqrb
– Bacco