nasaa
nasaa

Reputation: 2731

trouble with htaccess rewriterule

I am trying to write a rewrite rule for the following URL from

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

to

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

I tried a few rewrite rule like the following but it does not work -

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

Any help will be highly appreciated.

Upvotes: 1

Views: 20

Answers (1)

anubhava
anubhava

Reputation: 784888

Try this rule:

RewriteEngine on

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

Upvotes: 1

Related Questions