【问题标题】:When i add forward slash after blog then it's not working当我在博客后添加正斜杠时它不起作用
【发布时间】:2016-01-26 13:15:27
【问题描述】:
<IfModule mod_rewrite.c>
    RewriteEngine on   # Turn on the rewriting engine
    RewriteRule ^blog-([a-zA-Z0-9_-]+)$ blog_detail.php?id=$1
</IfModule>

基本上我想要类似的 URL - http://www.hostname.org/blog/anything

但现在显示 - http://www.hostname.org/blog-anything(它工作正常)

请帮忙!

【问题讨论】:

  • 所以你想把你的“破折号”改成“斜线”...RewriteRule ^blog/([a-zA-Z0-9_-]+)$ blog_detail.php?id=$1

标签: regex .htaccess mod-rewrite url-rewriting friendly-url


【解决方案1】:

根据我对您的问题的理解:

RewriteEngine On

RewriteRule ^blog-([\w-]+)$ /blog/$1 [R=301,L,NC]
RewriteRule ^blog/([\w-]+)/?$ /blog_detail.php?id=$1 [L,NC]

【讨论】:

    猜你喜欢
    • 2013-08-31
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-06
    • 1970-01-01
    • 2011-05-26
    • 2018-02-27
    相关资源
    最近更新 更多