Reputation: 53
I need to escape the "?" character in the url, so that it works with rewritten urls like search/why-is-it?-1.html
I currently have the following in .htaccess
RewriteEngine on
RewriteRule ^search/(.*)-([0-9]+).html$ index.php?search=$1&page=$2 [L]
Thanks
Upvotes: 4
Views: 1538
Reputation: 490123
Don't put a question mark in your URLs. The ?
is reserved for the start of the query string.
To place it in a URL, encode it as %3F
.
Read the RFC and this answer.
If using PHP (and it looks like you are), you could do something like this (page requested is index.php/inter?net
)...
<?php
var_dump($_GET);
$urlTokens = explode('/', $_SERVER['REQUEST_URI']);
$slug = end($urlTokens);
var_dump($slug);
array(1) {
["net"]=>
string(0) ""
}
string(9) "inter?net"
You can see $_GET
is confused.
Upvotes: 6