Period . sends page to 404, but only on some URLs..
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Period . sends page to 404, but only on some URLs..
We are building filters for a website.
Some of the filters have full stops in them. ie. 0.77 CAL.
In the URL, that is converted into /all-products&calibre=0.77-cal.
If I go to that page, I get a 404 error.
However, if I use that same query on the end on a category page, or a search page as follows, I don't get a 404.
/index.php?page=guns&category=all&calibre=0.77-cal
/categ/special-ops&calibre=0.77-cal
This is the HTACCESS rewrite for the one with the issue:
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
This is it for the category that works:
RewriteRule ^categ/([^/]+)$ /index.php?page=categ&cname=$1 [L]
If I use a calibre filter that has no . in it, it works.
Some of the filters have full stops in them. ie. 0.77 CAL.
In the URL, that is converted into /all-products&calibre=0.77-cal.
If I go to that page, I get a 404 error.
However, if I use that same query on the end on a category page, or a search page as follows, I don't get a 404.
/index.php?page=guns&category=all&calibre=0.77-cal
/categ/special-ops&calibre=0.77-cal
This is the HTACCESS rewrite for the one with the issue:
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
This is it for the category that works:
RewriteRule ^categ/([^/]+)$ /index.php?page=categ&cname=$1 [L]
If I use a calibre filter that has no . in it, it works.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
Shouldn't those & be ?simonmlewis wrote: In the URL, that is converted into /all-products&calibre=0.77-cal.
...
/categ/special-ops&calibre=0.77-cal
Re: Period . sends page to 404, but only on some URLs..
That rule will not match this URI: /categ/special-ops&calibre=0.77-calsimonmlewis wrote: This is the HTACCESS rewrite for the one with the issue:
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
That rule reads "line begins with any number of characters that are not a forward slash or a full stop and optionally ends with a forward slash"
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Period . sends page to 404, but only on some URLs..
So I need to alter than rule to allow for a period?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
Well yes. Deliberately excluding full stops from a rule when you're expecting them in the URI is counterproductive.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Period . sends page to 404, but only on some URLs..
Sorry I worded that wrong. So how do I INCLUDE full stops to be eligible in the URL?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
You need to remove the \. from your exclude list, but you also need to allow for the category. Hard for me to say exactly what your rule should be without knowing about other use cases. Have you looked at the htaccess tester I linked earlier? Considered implementing a router so you're not stuck dealing with so much htaccess?
Re: Period . sends page to 404, but only on some URLs..
Something like this could work
[text]RewriteRule ^categ/([^\/]+)/?$ index.php?categ=$1 [QSA,L][/text]
but I have no way of knowing how it will interact with your other rules.
[text]RewriteRule ^categ/([^\/]+)/?$ index.php?categ=$1 [QSA,L][/text]
but I have no way of knowing how it will interact with your other rules.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Period . sends page to 404, but only on some URLs..
The category works fine.
It's the root one that fails. so /all-product&calibre=0.77-cal
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
It's the root one that fails. so /all-product&calibre=0.77-cal
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
Still need to remove the full stop exclusion, so
[text]RewriteRule ^([^/]+)/?$ index.php?page=$1 [L][/text]
[text]RewriteRule ^([^/]+)/?$ index.php?page=$1 [L][/text]
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Period . sends page to 404, but only on some URLs..
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L]
This is disallowing ALL URLs that are just /home for example.
This isn't live so there is no major panic here. But I don't know why it would cause that.
Right at the very top of the file is this, which I believe is to do with casing, but it has a full stop. could this be affecting it?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
This is disallowing ALL URLs that are just /home for example.
This isn't live so there is no major panic here. But I don't know why it would cause that.
Right at the very top of the file is this, which I believe is to do with casing, but it has a full stop. could this be affecting it?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
Let's back up a second before we get too deep down the htaccess rabbit hole. What is it specifically that you're trying to do and is this rule even required?
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Period . sends page to 404, but only on some URLs..
Ok. This is for a website that sells products.
We have filters (mentioned in another thread).
There are filters where the filter is for "calibre", and could be 0.77 CAL. Mostly with a full stop in them.
On Categories, the filter works.
On this page, which is /all-products, it has the filter, but when you select any filter with the full stop it in, it goes to a 404. (a custom 404 i might add).
We have filters (mentioned in another thread).
There are filters where the filter is for "calibre", and could be 0.77 CAL. Mostly with a full stop in them.
On Categories, the filter works.
On this page, which is /all-products, it has the filter, but when you select any filter with the full stop it in, it goes to a 404. (a custom 404 i might add).
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Period . sends page to 404, but only on some URLs..
So where does htaccess even fit into this? Why isn't /all-products?calibre=0.77-cal sufficient?