Page 2 of 3

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 9:39 am
by simonmlewis
Ok I do have GETs there, but only becuase of the URL.
Nothing for $five.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 9:42 am
by simonmlewis
Oh and if I put "test=2" on the end of the URL, it does not show up in the array.

With this at the start:
[text]array(7) [/text]
Surely ther should be 8!? if I have an eight on the end.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 9:43 am
by Celauran
And that's even with QSA in the RewriteRule? Where did you check for it (ie. where in the execution)?

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 9:46 am
by simonmlewis
Yes, with QSA. And it's just before the execution of the $five script.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 9:52 am
by Celauran
What about at the very beginning of index.php, before anything else executes?

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:02 am
by simonmlewis
If I put it literally after session_start:

Code: Select all

<?php session_start();
$five = isset($_REQUEST['five']) ? $_REQUEST['five'] : null;
if (isset($five)) { echo "<font color='#ff0000'>hi</font>";}
Still nothing echoes on screen.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:02 am
by Celauran
Let's see your .htaccess, then.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:07 am
by simonmlewis

Code: Select all

DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all 

Options +FollowSymLinks
Options +Indexes
RewriteEngine On

RewriteRule ^error/?$  /selectpage [QSA]

RewriteRule ^(blog)($|/) - [QSA]

RewriteRule ^knowledge/([0-9]+) /index.php?page=knowledge&id=$1 [QSA]
RewriteRule ^knowledge/answer/([0-9]+)/([0-9]+) /index.php?page=knowledge&id=$1&id_link=$2 [QSA]

RewriteRule ^pricedrop/page/([0-9]+)/ /index.php?page=pricedrop&pagenum=$1 [QSA]
RewriteRule ^productsnew/page/([0-9]+)/ /index.php?page=productsnew&pagenum=$1 [QSA]

RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=sub [QSA]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&menu=sub&pagenum=$3 [QSA]
RewriteRule ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [QSA]
RewriteRule ^subcateg/page/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub&pagenum=$5 [QSA]

RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5 [QSA]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [QSA]

RewriteRule ^productzoom/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=productzoom&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [QSA]
RewriteRule ^pricematch/([0-9]+) /index.php?page=pricematch&id=$1 [QSA]

RewriteRule ^type/([^/]+) /index.php?page=type&type=$1 [QSA]
RewriteRule ^use/([^/]+) /index.php?page=use&use=$1 [QSA]

RewriteRule ^romancode/([^/]+) /index.php?page=romancode&romancode=$1 [QSA]
RewriteRule ^productsall/([0-9]+)/ /index.php?page=productsall/ [QSA]

RewriteRule ^productsall/page/([0-9]+)/ /index.php?page=productsall&pagenum=$1/ [QSA]
RewriteRule ^manufacturers/([^/]+) /index.php?page=manufacturers&manufacturer=$1 [QSA]

RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [QSA]

RewriteRule ^$ index.php?page=home [QSA]

RewriteRule ^robots.txt$ robots.php [QSA]

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:11 am
by Celauran
And if you reverse the order of these two rules?

Code: Select all

RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5 [QSA]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5&h=$6 [QSA]
The more specific rule should come first.

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:25 am
by simonmlewis
Well damn me, it worked.
Why would that cause it to not work then in the other order?

Re: HTACCESS - can you duplicate a line?

Posted: Tue Oct 07, 2014 10:27 am
by Celauran
Because it was matching the less specific rule first and rewriting the request like you asked it to.

Re: HTACCESS - can you duplicate a line?

Posted: Thu Oct 09, 2014 11:43 am
by simonmlewis
Here is a simple problem with URLs and potentially HTACCESS.
$power is set to "electric".

Code: Select all

<a href=\"/power/page/$power/$page/\" class='pagelink'>[Next]</a>

Code: Select all

RewriteRule ^power/([^/]+) /index.php?page=power&power=$1 [QSA]
RewriteRule ^power/page/([0-9]+)/([^/]+) /index.php?page=power&pagenum=$1&power=$2 [QSA]
When it opens, and on the first pages it's just:
/power/$power.
such as ".../power/electric".

When I hover over the [next] link it shows /power/page/electric/2/.
But when the page turns over, it replaces the content of $power" with the word "page".
Doing the _GET dump, I get this:
[text]array(2) { ["page"]=> string(5) "power" ["power"]=> string(4) "page" } Array ( [page] => power [power] => page ) page, 1[/text]

I've no idea why. We use this style for categories and other pages. If I remove the second rewriterule, oddly we get no errors, and the same problem.
So maybe it is just ignoring the rule? Same happens if I switch the order of the rules.

Re: HTACCESS - can you duplicate a line?

Posted: Thu Oct 09, 2014 12:27 pm
by Celauran
And if you switch the order and change [QSA] to [L,QSA]?

Re: HTACCESS - can you duplicate a line?

Posted: Thu Oct 09, 2014 1:34 pm
by simonmlewis
Bingo - what is L,QSA then?

Re: HTACCESS - can you duplicate a line?

Posted: Thu Oct 09, 2014 1:57 pm
by Celauran
L is 'last', QSA is 'query string append'

http://httpd.apache.org/docs/2.2/mod/mo ... ewriterule