【问题标题】:Mod Rewrite not working as visually intended with multiple dashes (-)使用多个破折号 (-) 时,Mod Rewrite 无法按视觉预期工作
【发布时间】:2013-12-04 20:26:49
【问题描述】:

所以我正在尝试使用 .htaccess 重写我的 mod 以按照我的意愿工作,但这似乎不起作用,我所拥有的:

index.php?id=concept-art-artist&artist=Marek-Okon

应该改为:

concept-art-artist-Marek-Okon

我的模组重写:

RewriteEngine On
RewriteRule ^([^-]*)-([^-]*)$ /index.php?id=$1&artist=$2 [L]

当导航到新的 URL 时出现 404 错误,是不是不可能以这种方式进行?

希望有人能解释一下!谢谢:)

【问题讨论】:

    标签: php mod-rewrite


    【解决方案1】:

    这应该会给你你想要的:

    RewriteEngine On
    RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)$ index.php?id=$1$2$3&artist=$4$5 [L]
    

    【讨论】:

    • 谢谢你的回复,concept-art-artist 是一个文件concept-art-artist.php,&artist 是要解析的信息,好像不像marek 之间的- -okon,因为如果我更改为 marek_okon,它会正常工作!
    • 你还有其他的重写规则吗?
    猜你喜欢
    • 2014-11-26
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    • 1970-01-01
    • 2020-12-02
    • 1970-01-01
    • 1970-01-01
    • 2020-05-08
    相关资源
    最近更新 更多