Search code examples
.htaccesshttp-redirecttypo3realurl

redirect part of url if query-var exists


I have relaunched a TYPO3 Website and have a problem with the redirects of old links listed by google. I want to redirect this:

https://www.mydomain.ac/index.php?id=88&itemID=123

to

https://www.mydomain.ac/item/item-detail/?itemID=123 

The id 88 is fix. It still does not exists in the new site, but maybe can be added later. So I just want to redirect if the id=88 AND an itemID (any number) is in the URL. I tried this:

RewriteRule ^index\.php\?id=88&itemID= /item/item-detail/?itemID= [L]

but this didn't work ... obviously ;-)

Any idea how to solve this? Thanx in advance!


Solution

  • You need a RewriteCond too.

    You can test it here: http://htaccess.mwl.be/

    RewriteCond %{QUERY_STRING} ^id=88&itemID=([0-9]*)$
    RewriteRule ^index\.php$ https://www.mydomain.ac/item/item-detail/?itemID=%1 [L]