htaccess rewriterule的问题

时间:2016-03-15 17:38:43

标签: regex apache .htaccess mod-rewrite

我正在尝试为

中的以下网址编写重写规则

https://example.com/news/lifestyle-magazines-4/chrissy-teigen-gets-her-kit-off-for-the-september-s-issue-of-women-s-health--4184/

https://example.com/news/?view=read&newsArticleID=4184

我尝试了一些如下所示的重写规则,但它不起作用 -

RewriteEngine on
rewriterule ^news/([A-Za-z0-9-]+)([^--]*)$ /news/?view=read&newsArticleID=$2 [L]

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:1)

尝试此规则:

RewriteEngine on

RewriteRule ^news/.*-(\d+)/?$ news/?view=read&newsArticleID=$1 [L,QSA,NC]