2

These are two different requests. the articles are both urlencoded() in PHP. The first request will match but the second wouldn't probably because of the question mark (? or %3F); they both have the plus sign (+ or %2B)

Here is my .htaccess rule

RewriteRule ^article~([^.]+)$ web/news/article.php?article=$1

My requests:

1

article~The-best-Android-Wear-smartwatch%2B12

2

article~Google-Play-Store-not-working%3F-Here-are-some-possible-fixes%2B10

I suspected that the presence of a question mark (? or %3F) in the second request could prevent it from working as it generate error code 403 (Access forbidden!).

iKev61
  • 176
  • 1
  • 11
  • Why do you have `article~` and not `article=` in your expression? – ʰᵈˑ Oct 10 '16 at 13:01
  • @hd I intended to forward all `article~` to `article=` i.e if you visit `article~blah-blah` on your browser, PHP should see it as `aticle=blah-blah` that's the point. – iKev61 Oct 10 '16 at 13:47
  • Ah I got confused because your expression has `~` but your examples had `=` – ʰᵈˑ Oct 10 '16 at 13:54
  • if you're using PHP to formulate the URL it's much easier just to strip out non alphanumeric/dash characters from the URL line, it sure beats messing around with `htaccess` edgecases, because SEO doesn't care about `?` and nor do your site visitors – Martin Oct 10 '16 at 13:54
  • Also please check [This StackOverflow Question](http://stackoverflow.com/questions/459667/how-to-encode-special-characters-using-mod-rewrite-apache). (both top two answers may be of interest to you) – Martin Oct 10 '16 at 13:55
  • @Martin That's could be a very nice idea, though I might be in trouble of stripping all non alphanumeric from my published posts URL (let me take that as **plan B** perhaps there would be a better solution). Thanks – iKev61 Oct 10 '16 at 14:15
  • How does your destination page load the data, does it search for the GET parameter in the Database? (I mean, does it matter what the title actually is?) – Martin Oct 10 '16 at 14:25

0 Answers0