Anatol
Anatol

Reputation: 2033

.htaccess remove part of url

I´m not feeling good asking this question (there are already a lot of good answers + tuts here). But after hours of trial I need help.

THE PROBLEM:

Due to an CMS Migration URLs have changed a bit. Old URLs are safed in a Database. Before I change ever link in Mysql I thought it would be much faster to do an .htaccess rewrite of those links. What I want is:

change

index.php/aktuelles?id=369:netzwerk-forst-und-holz-unterfranken-startet-ab-12-2012-&catid=1:news

to

index.php/369:netzwerk-forst-und-holz-unterfranken-startet-ab-12-2012-&catid=1:news

means simple cut the

aktuelles?id=

of the URL. Here my trials:

RewriteEngine On
Options +FollowSymLinks

RewriteRule ^aktuelles\?id\=$ $1 [R=301]
#RewriteRule (.*)/index.php/aktuelles?id=(.*) $1/$2 [R=301]

Thanks a lot for your help,

kind regards,

tony

Upvotes: 1

Views: 694

Answers (1)

ConcurrentHashMap
ConcurrentHashMap

Reputation: 5084

Here you go. This should cut out the aktuelles?id= from the provided URL:

RewriteCond %{QUERY_STRING} ^id=([^]+]+)$
RewriteRule ^([^/]*)/(aktuelles)$ $1/%1? [L, R=301]

It's untested - please tell me if this worked for you.

Upvotes: 1

Related Questions