PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 9:22 am
Code: Select all
http://test.local/seller/807&simon=y
My code isn't collating this $simon variable.
Code: Select all
$simon= isset($_GET['simon']) ? $_GET['simon'] : null;
echo "$simon";
echo "
<a href='/seller/$id&simon=y'>test</a>";
Are you now allowed to put a & after a number in the URL? I'm trying to run an "order by" based on a $sorder variable. But it won't work. so I tried it with $simon to see if that is passed through, but it isn't. I don't understand why. It's not echoing "$simon".
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 18, 2014 9:46 am
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 9:51 am
No that doesn't work either.
Changing the url to $id?simon=y, makes no difference.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 18, 2014 9:56 am
Sounds like the issue is with rewrite rules, then. What are those?
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 10:00 am
This is the one that rewrites the seller products page:
Code: Select all
RewriteRule ^seller/([0-9]+) /index.php?page=productsseller&id=$1&menu=home [L]
And this is a category page - the 'sort' works on this one:
Code: Select all
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=home [L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 18, 2014 10:03 am
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 11:00 am
I've not seen that before.
If I do this:
Code: Select all
RewriteRule ^seller/([0-9]*)? /index.php?page=productsseller&id=$1&menu=home [QSA]
The page is not found.
But this
Code: Select all
RewriteRule ^seller/([0-9]+) /index.php?page=productsseller&id=$1&menu=home [QSA]
Page is found, but the issue I have raised, remains.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 11:02 am
Incidentally, if I do this:
Code: Select all
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=home [L]
And put ... &order=title, on the end of the rewritten URL, it works!!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 18, 2014 11:19 am
And if you do this?
Code: Select all
RewriteRule ^seller/([0-9]*)? /index.php?page=productsseller&id=$1&menu=home [QSA, L]
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Tue Mar 18, 2014 12:31 pm
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
site.local
Apache/2.4.4 (Win32) OpenSSL/1.0.1e PHP/5.5.1
Code: Select all
DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^messages/([0-9]+) /index.php?page=messages&threadid=$1&menu=home [L]
RewriteRule ^seller/([0-9]*)? /index.php?page=productsseller&id=$1&menu=home [QSA, L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Tue Mar 18, 2014 1:11 pm
Sorry, there shouldn't be a space between QSA and L.
Code: Select all
RewriteRule ^seller/([0-9]+)/? /index.php?page=productsseller&id=$1&menu=home [QSA,L]
works fine for me
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Wed Mar 19, 2014 4:32 am
Well I'll be damned, it works.
What is the difference between using & with [L] and using it in that other method?
Is it a newer method?
Odd that the other way works on my category page, but not this page.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Celauran
Moderator
Posts: 6427 Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada
Post
by Celauran » Wed Mar 19, 2014 8:34 am
They're different rules. QSA is query string appended, ensuring things don't get "lost" in the rewrite. L is last, meaning stop processing rules.
simonmlewis
DevNet Master
Posts: 4435 Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:
Post
by simonmlewis » Wed Mar 19, 2014 8:39 am
So how is my category script working, if that uses the same "order" values in the URL?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.