Hakon-testers
Hakon-testers

Reputation: 11

Htaccess rewrite issue when redirecting from one dynamic url to another

I am looking to rewrite a URL from current dynamic structure..

www.domain.com/news/news.php?news=id

to this new

www.domain.com/?p=id

the id is a dynamically number-based id.

I have tried multiple solutions for this, but it seems like I am not good enough at htaccess, because I can't get it to work.

Anyone with a good solution?

Upvotes: 0

Views: 23

Answers (1)

anubhava
anubhava

Reputation: 784968

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} (?:^|&)news=([^&]+) [NC]
RewriteRule ^news/news\.php$ /?p=%1 [L,NC]

Upvotes: 1

Related Questions