开发者

.htaccess removes trailing periods from query

Having some trouble where .htaccess is removing the trailing period from strings. I am running Apache/2.2.12 (Win32).

This is not a production system, so there is nothing else in .htaccess other than:

RewriteEngine on  

...and rules, and this works well in all cases so far, unless there is a trailing period in the name. Rules all take the form of:

RewriteRule ^thing/(.*)$ showthing.php?thingname=$1

A link on A.php:

<a href="thing/M.O.X."> ...CLICK

So in showthing.php, I simply do:

$sTHINGname= !isset($_REQUEST['thingname']) ? NULL : $_REQUEST['thingname'];

...then $sTHINGname is run though the db to find the ID.

The trouble is that when thingname has a trailing period (e.g.: "M.O.X.")

echo $sTHINGname;  // shows M.O.X, which does not match an ID

One solution is to do:

str_replace( '.', '%2E', $name );  

But when the links are placed in the referring page (A.php), and this works, but the links read:

<a href="thing/M开发者_JAVA百科%252EO%252EC%252E">

...which is a bit inelegant and does not solve the problem, because if a user types as a URL "...thing/M.O.X." they still don't get a result.

I checked out replacing $_REQUEST with $_GET, but the result doesn't change. Also:

RewriteRule ^(thing/)(.*)$ showthing.php?thingname=$2  

...and variations all show the same results.

Most search results dealing with htaccess and periods are domain issues, so I wonder if anyone has any ideas about this one?


Try this:

RewriteRule ^thing/(.+)$ showthing.php?thingname=$1 [L,QSA]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜