【问题标题】:how to remove dot in an url through htaccess如何通过htaccess删除网址中的点
【发布时间】:2012-10-13 10:38:27
【问题描述】:

我收到某些 url 的 403 Access Forbidden 错误。我找到了问题的根本原因。只要网址中有一个点(。),我就会得到 403 禁止。

google 已经索引了数千个 url,因此我想通过 htaccess 解决。

例如

我想删除以下网址的(点)

来自

http://www.example.com/zero/one/two/three/four/five/six./seven/eight.html

http://www.example.com/zero/one/two/three/four/five/six/seven/eight.html

【问题讨论】:

标签: linux apache .htaccess mod-rewrite url-rewriting


【解决方案1】:

mod rewrite 应该可以做到这一点:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^.]*)\.([^.]*)\.?([^.]*)?\.?([^.]*)?\.?([^.]*)?(\.html|php|asp|otherextenstionsdesiredhere$) $1$2$3$4 [NC]

应允许一次删除 1 到 3 个句点。如果您需要更多,只需重复一遍。如果最多只有 1 个周期,则去掉一部分。 您可以在http://regexpal.com/ 对其进行测试,并在http://corz.org/serv/tricks/htaccess2.php 阅读有关重写的更多信息

【讨论】:

    猜你喜欢
    • 2014-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    相关资源
    最近更新 更多