Hi David
I want to redirect search page likr
Original Page :
1) example.com/men/search.php?q=%3A&categoryFilter%5B%5D=T+Shirts
redirect to : example.com/men/t-shirts
2)example.com/men/search.php?q=%3A&page=2&sort=numMerchants&categoryFilter[]=T+Shirts
redirect to : example.com/men/t-shirts/2/
Thanks
Amin
technoarenasol
Hi David
I try 2 option :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ search.php?q=%3A&categoryFilter=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)/(.*)/$ search.php?q=%3A&categoryFilter=$1&page=$2&rewrite=1&%{QUERY_STRING} [L]
This rules not working...
Thanks
Amin
technoarenasol
David also possible to redirect more than 2 filter in URL
Like
Brand name=puma
example.com/men/t-shirts
example.com/men/t-shirts/puma
example.com/men/t-shirts/2/
example.com/men/t-shirts/puma/2/
Hi Amin,
My apologies, the rules included a superfluous leading "/" - to correct this and include the brand filter options also (this has to be done in a specific order so that the differences can be resolved) have a go with:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)/$ search.php?q=%3A&categoryFilter=$1&brandFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/$ search.php?q=%3A&categoryFilter=$1&page=$2&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ search.php?q=%3A&categoryFilter=$1&brandFilter=$2&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ search.php?q=%3A&categoryFilter=$1&rewrite=1&%{QUERY_STRING} [L]
Cheers,
David.
--
PriceTapestry.com
Hi Amin,
Non based rules (e.g. with nothing generic in the URL) can be fiddly and their position and order within .htaccess is absolutely crucial; please could you email me your latest .htaccess and search.php files and I'll check them out in full for you...
Thanks,
David.
--
PriceTapestry.com
Hello David,
I hope you are well.
Did you find a solution ?
I have the same problem. Blank page.
The brandFilter (first) works but not the categoryFilter.
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cat/(.*)/(.*)/$ search.php?q=category:$1:&brandFilter=$2&rewrite=1&%{QUERY_STRING} [L,B]
RewriteRule ^cat/(.*)/(.*)/(.*).html$ search.php?q=category:$1:&brandFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cat/(.*)/(.*)/$ search.php?q=category:$1:&categoryFilter=$2&rewrite=1&%{QUERY_STRING} [L,B]
RewriteRule ^cat/(.*)/(.*)/(.*).html$ search.php?q=category:$1:&categoryFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L,B]
Hi,
You're using the same base component "cat" so only the first rules would take effect - did you mean to use something like "mer" and merchantFilter (as category:Category Name? Also note that RewriteCond statements need to preceed every rule - they only apply to the next RewriteRule - for example:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cat/(.*)/(.*)/$ search.php?q=category:$1:&brandFilter=$2&rewrite=1&%{QUERY_STRING} [L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cat/(.*)/(.*)/(.*).html$ search.php?q=category:$1:&brandFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mer/(.*)/(.*)/$ search.php?q=category:$1:&merchantFilter=$2&rewrite=1&%{QUERY_STRING} [L,B]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mer/(.*)/(.*)/(.*).html$ search.php?q=category:$1:&merchantFilter=$2&page=$3&rewrite=1&%{QUERY_STRING} [L,B]
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi Amin,
If you already have the .htaccess rules in place, look for the following code towards the top of search.php:
$rewrite = isset($_GET["rewrite"]);
...and REPLACE with:
$rewrite = isset($_GET["rewrite"]);
if (
(!$rewrite)
&& ($q==":")
&& ($categoryFilter<>"")
&& ($sort=="numMerchants")
&& ($merchantFilter=="")
&& ($brandFilter=="")
// include similar conditions for any other custom filters here
)
{
$location = $config_baseHREF.strtolower(tapestry_hyphenate($categoryFilter));
if ($page > 1) $location .= "/".$page."/";
header("Location: ".$location);
exit();
}
If you don't have the rules in place yet, since there is no common prefix in your desired clean URLs (e.g. /category/) then they should be placed last in .htaccess together with the file / directory not exists conditionals - have a go with:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ search.php?q=%3A&categoryFilter=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)/(.*)/$ search.php?q=%3A&categoryFilter=$1&page=$2&rewrite=1&%{QUERY_STRING} [L]
Cheers,
David.
--
PriceTapestry.com