Redirect specific querystring in htaccess


Now i have this url structure:

In htaccess i now want to rewrite all /news?nid= to:

How do i do that?

Hi @thomsson and a warm welcome to the forum.

I believe the htaccess redirection is commonly called “pretty URLs” and further details can be found here:

Hi there @thomsson, welcome to the forums :wave:

What you want to use here is Apache’s RewriteEngine

Something like this:

Options -MultiViews +FollowSymlinks

RewriteEngine On
RewriteCond %{QUERY_STRING} nid=(.*?)($|&) [NC]
RewriteRule ^/?news /news/$1 [L,R=302]

Once that works (I haven’t tested it) you should replace 302 (temporary redirect) with 301 (permanent redirect).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.