Page 3 of 3

Re: HTACCESS - can you duplicate a line?

Posted: Fri Oct 17, 2014 8:14 am
by simonmlewis
These links don't work.

When we choose A-Z for example, it doesn't update $order and put it in a sessionm it keeps it set to price1 ASC.

I don't think it's the code that's wrong, it's something within HTACCESS, as I don't believe it is even passing it through to the page, the final but of the URL to give it the Order instruction.

Code: Select all

RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&pagenum=$3 [L]

Code: Select all

if (!isset($_REQUEST['order']))
{
$order = "price1 ASC";
}
else if (isset($_REQUEST['order'])) {
    $order = $_REQUEST['order'];
    $_SESSION['order'] = $_REQUEST['order'];
} else if (isset($_SESSION['order'])) {
    $order = $_SESSION['order'];
}

echo "<div class='";
if(isset($order))
{
if ($order == "title ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title ASC' style='text-decoration: none'>A-Z</a></div>";

echo "<div class='";
if(isset($order))
{
if ($order == "title DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=title DESC' style='text-decoration: none'>Z-A</a></div>

<div class='";
if(isset($order))
{
if ($order == "price1 ASC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}

echo "'><a href='/categ/$c/$categreplace&order=price1 ASC' style='text-decoration: none'>Price (Low-High)</a></div>

<div class='";
if(isset($order))
{
if ($order == "price1 DESC") { echo "categ_subcategon";}
else
{
echo "categ_subcateg";
}
}
echo "'><a href='/categ/$c/$categreplace&order=price1 DESC' style='text-decoration: none'> (High-Low)</a></div><div style='clear: both; width: 500px'/></div><br/>";

echo "$order<div style='clear: both' /></div>";

Re: HTACCESS - can you duplicate a line?

Posted: Fri Oct 17, 2014 8:19 am
by Celauran
simonmlewis wrote:These links don't work.

When we choose A-Z for example
What does this mean? Please provide some sample URLs (i.e. obfuscate the domain if you want, but keep everything else accurate) alongside your rewrite rules. Complete .htaccess would also be handy in case things are matching earlier rules.

Re: HTACCESS - can you duplicate a line?

Posted: Fri Oct 17, 2014 8:21 am
by simonmlewis
Apologies

http://www.domain.co.uk/categ/87/Aged-S ... der=price1 DESC

Code: Select all

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

RewriteEngine On
Options +FollowSymLinks
Options +Indexes

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

RewriteRule ^aboutus/?$  /showroom [L]
RewriteRule ^testimonial_uploads/page/([0-9]+) /index.php?page=testimonial_uploads&pagenum=$1 [L]

RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
RewriteRule ^categ/page/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=categ&c=$1&cname=$2&pagenum=$3 [L]
RewriteRule ^ancillaries/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=ancillaries&c=$1&category=$2&product=$3&h=$4 [L]
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&category=$2&product=$3&h=$4 [L]
RewriteRule ^sample/([^/]+) /index.php?page=sample&c=$1 [L]
RewriteRule ^productsall/([0-9]+)/ /index.php?page=productsall&pagenum=$1/ [L]

RewriteRule ^news/([0-9]+)/([^/]+) /index.php?page=news&id=$1&title=$2 [L]

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

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

Re: HTACCESS - can you duplicate a line?

Posted: Fri Oct 17, 2014 8:30 am
by Celauran

Code: Select all

RewriteRule ^categ/([0-9]+) /index.php?page=categ&c=$1 [L]
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2 [L]
Switch the order of these and add QSA

Re: HTACCESS - can you duplicate a line?

Posted: Fri Oct 17, 2014 9:39 am
by simonmlewis
You beauty - what different technically does that make then (yes it worked !! :) )