Page 1 of 3
HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 7:35 am
by simonmlewis
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&h=$6 [L]
This is our product page htaccess for a site we run.
Some folks are trying or found link that don't use the h=$6 on the end, the result is they get an error page.
Is there a simple way to get around this?
ie. Two types of /product pages, that cater for both?
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 7:39 am
by Celauran
Creating a second rule without the last capture group and without the &h=$6 isn't cutting it?
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 7:42 am
by simonmlewis
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 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&menu=sub&product=$5 [L]
We are getting Object Not Found, when we use it without the final /PROD_NAME .
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 7:45 am
by Celauran
And you're certain that's an .htaccess issue? You've tried the query string manually and it returns the desired results?
Also, can you provide some sample links?
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 7:48 am
by simonmlewis
IF the URL is normally:
www.simon.com/product/2/tall/5/red/456/shirt
Then this is what's getting errors:
www.simon.com/product/2/tall/5/red/456
That's it in a nutshell!
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 8:21 am
by Celauran
Celauran wrote:And you're certain that's an .htaccess issue? You've tried the query string manually and it returns the desired results?
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 8:23 am
by Celauran
Oh, I see. You didn't remove the last capture group from the regex. What about this?
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 [L]
Re: HTACCESS - can you duplicate a line?
Posted: Mon Oct 06, 2014 8:43 am
by simonmlewis
Bingo - that was it. Can't believe I missed that!!
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 8:32 am
by simonmlewis
Would it caused a problem for me to post a URL like this, and be able to capture the $five variable?
http://site.local/product/80/BUNDLE-OFF ... SET&five=5
This is not using "five" at all. and the HTACCESS is as you suggested it should be. I've tried it with [QSA] as well.
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 8:44 am
by Celauran
Works fine for me as is. What problem are you encountering?
$_GET:
Code: Select all
Array
(
[page] => product
[c] => 80
[cname] => BUNDLE-OFFERS
[s] => 44
[sname] => MONEY-SAVERS
[menu] => sub
[product] => 333
[h] => SPECIAL-410-SET
[five] => 5
)
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 8:49 am
by simonmlewis
When sent, this is the code I am running, and it worked fine but since something I have changed, it now stops.
Code: Select all
$five = isset($_GET['five']) ? $_GET['five'] : null;
if (isset($five))
{
if ($five == "3" || $five == "4" || $five == "5")
{
$counter = 0;
while ($counter < $five)
{
mysql_query ("INSERT INTO rating (prodid, stars) VALUES ('$myprod', '$five')");
$counter = $counter + 1;
}
mysql_query ("UPDATE products SET staroverride = '$five' WHERE id = '$myprod'");
}
Even if I just put it like this:
Code: Select all
$five = isset($_GET['five']) ? $_GET['five'] : null;
if (isset($five))
{
echo "hi there";
}
Nothing comes up.
It simply doesn't nothing "extra" on screen.
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 9:08 am
by simonmlewis
It doesn't matter what I use - if I capture $fred, and then echo that, it won't echo it, so for some reason it won't let me put anything oni the end of the url.
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 9:24 am
by Celauran
Have you checked the contents of $_GET? What other scripts does it go through before arriving at the above? Have you checked those as well?
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 9:30 am
by simonmlewis
Sorry to be dumb, but how do I see what is in $_GET? I can understand your thinking and I reckon you could be right. Though "$five" is not used elsewhere.
IS it just $test = $_GET;??
Re: HTACCESS - can you duplicate a line?
Posted: Tue Oct 07, 2014 9:36 am
by Celauran
Either of these will work.
You might want to wrap it in <pre> tags, and maybe call exit afterward to stop execution from continuing. Really, you ought to be using something like XDebug, but that's for another time.