圆点的网址被剥离圆点、网址

2023-09-02 20:37:40 作者:要来一个西瓜吗

我有一个网址 - 的http://木卫四/新闻/ 1st_February_is_here ... - 其中有三个圆点,但当时它被通过传递mod_rewrite的并到达脚本(在$ _GET)的点已经被移除(但串的其余部分是行)。

I've got a url - http://callisto/news/1st_February_is_here... - which has three trailing dots, but by the time it gets passed through mod_rewrite and reaches the script (in $_GET) the dots have been removed (but the rest of the string is OK).

这是htaccess的规则:

This is the htaccess rule:

RewriteRule ^([^/]+)/(.*)$ index.php?__action=site&__filter=$1&__page=$2 [L,QSA]

感谢。

推荐答案

我想你正在使用的职位或类似的在你的URI中的第三个位置的东西称号。由于这样的事实,你很可能有很多其他的'破'字来通过你的URI用这种方法,我建议你将其附加到URI之前清洗称号,并放置在同一洁净的字符串到数据库,以供参考。

I take it you are using the title of a post or something similar as the third position in your URI. Due to the fact that you could probably have a lot of other 'breaking' characters come through your URI with this method I would suggest that you cleanse the title before appending it to the URI and place the same cleansed string into your database for reference.

卸下非字母数字的任何字符,然后换上连字符空格-'--这将确保你不会进一步下跌的线混淆任何东西,或碰到任何浏览器,使您的URI从工作的具体问题。

Remove any characters that aren't alphanumeric and replace spaces with a hyphen '-'--this will ensure that you don't confuse anything further down the line or bump into any browser specific issues that keep your URI from working.

$title = '1st February is here...';
$clean_title = preg_replace('/[^a-zA-Z0-9s]/', '', $title);
$finished_title = str_replace(' ', '-', $clean_title);

运行code aboce将清理你的标题。

Running the code aboce will clean your title.

http://callisto/news/1st_February_is_here...

应该成为:

http://callisto/news/1st-February-is-here

或类似的东西。我建议一个连字符,而不是下划线的唯一原因是,我,有时不得不用下划线问题被传递的URI。

Or something similar. The only reason I suggest a hyphen instead of an underscore is that I have, on occasion, had issues with underscores being passed in the URI.

另外,我想你会发现这是Word preSS采用的方法 - 最有可能的,你看到了这个问题,同样的道理

Also, I think you will find this is the method that Wordpress employs--most likely for the same reason that you are seeing this issue.

GL!