Page 1 of 3
Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 10:52 am
by simonmlewis
We are upgrading our website, part of this is shortening the URLs.
But I've come across a hitch that I didn't think would be a problem anyway.
If a URL has a + in it, like "BATTERY-+-CHARGER", it doesn't like it.
Yet the live site that hasn't been updated yet, is fine with it.
This is the htaccess, which I suspect is the cause of this.
Code: Select all
# old url style
RewriteRule ^product/([0-9]+)/([^/]+)/([0-9]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&c=$1&cname=$2&s=$3&sname=$4&product=$5&h=$6 [QSA]
# new url style
RewriteRule ^product/([^/]+)/([^/]+)/([0-9]+)/([^/]+) /index.php?page=product&cname=$1&sname=$2&product=$3&h=$4 [QSA]
In firefox, I'm being taken to a :
The page isn't redirecting properly
page.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 10:55 am
by Celauran
Can you post an example URI?
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:03 am
by simonmlewis
Sadly not sorry. but a dummy version would be:
http://www.website.co.uk/product/shirts ... ts-+-socks
This would page would fall over.
But if it were this:
http://www.website.co.uk/product/shirts ... -and-socks
it would be fine.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:06 am
by Celauran
Good enough. Didn't need to be a real URL. Obfuscating client names etc is always fine.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:08 am
by simonmlewis
Cool - leave it with you then to see if you can spot the issue.
I'm sure having both URLs in the htaccess is fine, as they are different structures. It's flawed me. At first I thought it was a missing product, but if it is not there it goes to a nicer page than a 404.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:10 am
by Weirdan
Wasn't plus sign used as a substitution for space character? What's the redirect url your browser is getting?
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:11 am
by Celauran
Weirdan is exactly right.
[text]array (size=5)
'page' => string 'product' (length=7)
'cname' => string 'shirts-and-socks' (length=16)
'sname' => string 'new-shirts-socks' (length=16)
'product' => string '3131' (length=4)
'h' => string 'xl-shirts- -socks' (length=17)[/text]
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:13 am
by simonmlewis
Then why does it work on our live site? that uses UTF-8.
In between each category name would be a /111/ type number configuration, but with the title of the product on the end.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:18 am
by simonmlewis
the other issue is, we have some products with titles like "Simons best++" for example.
So I cannot just remove all the + signs. Specially since at the moment... they work!
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:19 am
by simonmlewis
Weirdan wrote:Wasn't plus sign used as a substitution for space character? What's the redirect url your browser is getting?
How do I find that out?
The URL remains on that page. but shows the error quoted.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:25 am
by Celauran
simonmlewis wrote:Weirdan wrote:Wasn't plus sign used as a substitution for space character? What's the redirect url your browser is getting?
How do I find that out?
Network tab in your browser's console (F12 in Firefox). Type URL into address bar, check for 301 or 302.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 11:30 am
by simonmlewis
It's trying to load the page, about 20 times, all as 301.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 1:08 pm
by Weirdan
So it appears there's a redirect loop. I wonder if you actually need to do external redirect (301/302 response sent to browser). From my experience, it's usually internal redirect (page served to browser without changing the url in the address bar) that people want.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 1:19 pm
by simonmlewis
Sorry? I'm not with you. This happens ONLY on pages with the + in the URL. If a product page doesn't exist, it throws it to an error page. But this isn't "going" anywhere. The URL remains, and it goes to a standard browser error page.
Re: Browser not accepting "+" in the title in the URL
Posted: Thu Jan 28, 2016 2:16 pm
by Weirdan
There shouldn't be any 30x responses. The fact that there are external redirects suggests there's something else at play.
You may try adding B (escape special chars) and L (stop processing) flags to your rules, but it's a stab in the dark. You shouldn't have used reserved characters in urls in the first place. And using them in two parts of the urls (path and query string, that have different sets of allowed characters) only complicates this situation.