Page 2 of 3

Re: Period . sends page to 404, but only on some URLs..

Posted: Mon Nov 07, 2016 1:38 pm
by simonmlewis
What do you mean, where does it fit into this?

Sorry you have really lost me there...................
I need it to manage /all-products.
But with that query on the end with the full stop, it breaks it. Hence this thread.

Re: Period . sends page to 404, but only on some URLs..

Posted: Mon Nov 07, 2016 1:48 pm
by Celauran
So no routing, everything is handled through htaccess? Can you post your rules, then? I've posted rules that do what you're asking, but they're apparently conflicting with other rules that I can't see. Kinda flying blind here.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 3:40 am
by simonmlewis
Pardon the length of confusing nature of it. We had a change of structure, but kept old ones to aid 301s to work.

The one in question is at the bottom.

Code: Select all

DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all 
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
ErrorDocument 404 /custom_404.php
# RewriteCond %{HTTPS} !=on
# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove multiple slashes after domain
RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]

# Remove multiple slashes anywhere in URL
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]


RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteRule ^(blog)($|/) - [QSA]
RewriteRule product-tags/bb-pellet$ /categ/bb-pellets? [R=301,L]


# old url rewrite
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 ^subcateg/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&menu=sub [L]
RewriteRule ^subcateg/page/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+) /index.php?page=subcateg&c=$1&cname=$2&s=$3&sname=$4&pagenum=$5 [L]

RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)$ /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&product=$5&h=$6 [L]
# end of old url rewrite


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

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

RewriteRule ^product/([^/]+)/([^/]+)/([0-9]+)/([^/]+)$ /index.php?page=product&cname=$1&sname=$2&product=$3&h=$4 [L]
# END OF NEW URLS

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 ^([^/]+)/page/([0-9]+) /index.php?page=$1&pagenum=$2 [L]

RewriteRule ^loadout/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=loadout&c=$1&cname=$2&s=$3&sname=$4&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/([^/]+)/([0-9]+)$ /index.php?page=use&use=$1&pagenum=$2 [QSA]
RewriteRule ^use/([^/]+) /index.php?page=use&use=$1 [QSA]

RewriteRule ^back-in-stock/page/([0-9]+)/([^/]+) /index.php?page=back-in-stock&pagenum=$1&power=$2 [L,QSA]

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

RewriteRule ^productsall/page/([0-9]+) /index.php?page=productsall&pagenum=$1/ [QSA]
RewriteRule ^productsairsoft/page/([0-9]+) /index.php?page=productsairsoft&pagenum=$1/ [QSA]
RewriteRule ^manufacturers/([^/]+) /index.php?page=manufacturers&manufacturer=$1 [QSA]
RewriteRule ^accessories-manufacturers/([^/]+) /index.php?page=accessories-manufacturers&manufacturer=$1 [QSA]
RewriteRule ^other-manufacturers/([^/]+) /index.php?page=other-manufacturers&manufacturer=$1 [QSA]
RewriteRule ^product-tags/page/([0-9]+)/([^/]+) /index.php?page=product-tags&pagenum=$1&producttag=$2 [QSA]
RewriteRule ^product-tags/([^/]+) /index.php?page=product-tags&producttag=$1 [QSA]
RewriteRule ^videos/([0-9]+) /index.php?page=videos&catid=$1 [QSA]
RewriteRule ^videos/product/([0-9]+)/([0-9]+) /index.php?page=videos&catid=$1&id=$2 [QSA]
RewriteRule ^videos/product-search/([0-9]+)/([0-9]+)/([^/]+)/([^/]+) /index.php?page=videos&catid=$1&id=$2&search=$3&searchvideo=$4 [QSA]

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

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

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

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:29 am
by Celauran
[text]RewriteRule ^productsall/page/([0-9]+) /index.php?page=productsall&pagenum=$1/ [QSA]
RewriteRule ^productsairsoft/page/([0-9]+) /index.php?page=productsairsoft&pagenum=$1/ [QSA]
RewriteRule ^manufacturers/([^/]+) /index.php?page=manufacturers&manufacturer=$1 [QSA]
RewriteRule ^accessories-manufacturers/([^/]+) /index.php?page=accessories-manufacturers&manufacturer=$1 [QSA]
RewriteRule ^other-manufacturers/([^/]+) /index.php?page=other-manufacturers&manufacturer=$1 [QSA][/text]

Any reason you aren't following a similar pattern for /all-products?

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:42 am
by simonmlewis
Those other pages don't have the filters. The filters just add to the URL... &calibre=0.77-cal.

Code: Select all

RewriteRule ^([^/]+)/page/([0-9]+) /index.php?page=$1&pagenum=$2 [L]
This is the rule that runs the all-products pagination.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:47 am
by Celauran
Have you looked at all at the tool I linked to? http://htaccess.madewithlove.be/
Seems like a good place to start

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:51 am
by Celauran
[text]RewriteRule ^all-products /index.php?page=all-products [QSA,L][/text]
This appears to be what you're after.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:57 am
by simonmlewis
While that isn't causing a 404, it's not passing over the additional queries in the URL.
Not even those filters we had that did work.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 7:59 am
by simonmlewis
Oh that's interesting, if I put that rule in after the one I mentioned earlier, that captures most /fred URLs, it works.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:00 am
by Celauran
What is the URI (you can of course obfuscate the URL)? What is the expected output? What is the actual output?

For input
[text]http://site.co.uk/all-products&calibre=0.77-cal[/text]

I get output
[text]http://site.co.uk/index.php?page=all-pr ... e=0.77-cal[/text]

Am I misunderstanding you?

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:01 am
by Celauran
simonmlewis wrote:Oh that's interesting, if I put that rule in after the one I mentioned earlier, that captures most /fred URLs, it works.
Hmm. Should do that anyway on account of the L

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:03 am
by simonmlewis
Ok sorry... correction. It passes most over. But Calibre, it doesn't 404, but it is not passing it through.
Even if I ask it if $calibre is isset, and echo something in the code, it still doesn't show anything.

URI: http://www.mysite.co.uk/all-products&calibre=.177-cal

The URI that appears at the top is rewritten, so index.php is not shown.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:11 am
by Celauran
simonmlewis wrote:Ok sorry... correction. It passes most over. But Calibre, it doesn't 404, but it is not passing it through.
Are you sure this is still an htaccess issue?
simonmlewis wrote:Even if I ask it if $calibre is isset, and echo something in the code, it still doesn't show anything.
Are other expected values being set? Can you tell if it's reaching the correct page script?

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:16 am
by simonmlewis
It is definitely to do with htaccess. If I echo "hello" in the:

Code: Select all

if(isset($_GET['calibre']))
... script, and click on a filter with a dot in it, nothing shows up.
If I select one with no dot in it, it does show.

If I select a manufacturer and echo similar code, it shows up.

So that full stop is definitely being barred somehow. Though it is no longer throwing a 404, it is not allowing it through.

Re: Period . sends page to 404, but only on some URLs..

Posted: Tue Nov 08, 2016 8:35 am
by Celauran
Can you post your modified htaccess? Do you know where it's failing?