【问题标题】:.htaccess isn't handling root of the folder properly.htaccess 没有正确处理文件夹的根目录
【发布时间】:2010-10-03 15:36:05
【问题描述】:

所以我在我的网络服务器上的 /blog/ 文件夹中有这个 .htaccess 文件,并与我们用于这个特定客户端(表达式引擎)的博客 CMS 一起工作,我编写了这个 .htaccess 以使 URL SEO 友好。这一切都很好,除非我去 www.example.com/blog/ 然后它会通过我不希望它的底部规则。

我尝试添加您可以在最后一行第二行看到的 Google 行,以查看它检测到的具体内容并通过 google“index.html”(无引号)——可能有一种简单的正则表达式方法来排除开头的字符串使用 index.html 但不幸的是我不是正则表达式忍者...

这是 .htaccess 的内容:

rewriteengine on



##############################
# BLOG CATEGORIES HOME

rewriterule ^beach-baby/?$ index.php/site/C4/
rewriterule ^adventure-baby/?$ index.php/site/C5/
rewriterule ^snow-baby/?$ index.php/site/C6/
rewriterule ^wild-child/?$ index.php/site/C7/



##############################
# BLOG CATEGORIES WITH PAGE NUMBER

rewriterule ^beach-baby/page([0-9]+)/?$ index.php/site/C4/P$1/
rewriterule ^adventure-baby/page([0-9]+)/?$ index.php/site/C5/P$1/
rewriterule ^snow-baby/page([0-9]+)/?$ index.php/site/C6/P$1/
rewriterule ^wild-child/page([0-9]+)/?$ index.php/site/C7/P$1/



##############################
# BLOG INDEX WITH PAGE NUMBER

rewriterule ^page([0-9]+)/?$ index.php/P$1/



##############################
# BLOG POST

#rewriterule ^([^/]+)/?$ http://www.google.ca/search?q=$1
rewriterule ^([^/]+)/?$ index.php/site/comments/$1/

【问题讨论】:

    标签: regex .htaccess


    【解决方案1】:

    您可以在其他规则之上设置以下规则以将/index.html 从其他规则中排除:

    RewriteRule ^index\.html$ - [L]
    

    【讨论】:

    • 原来我必须为 index.cgi、index.pl 和 index.php 做同样的事情
    猜你喜欢
    • 2018-05-28
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 2015-11-11
    • 1970-01-01
    • 1970-01-01
    • 2020-10-24
    相关资源
    最近更新 更多