简体   繁体   中英

.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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM