I want to redirect from a link like
index.php?site=recipes&id=2451 to recipes/2451
and in fact in works pretty good beside one thing.
First my whole htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.bla\.de/ [NC]
#RewriteRule ^(.*)$ http://www.bla.de/cocktails/$1 [R=301,L]
### Startseite
RewriteRule ^$ /cocktails/meine-bar [R=301,L]
### rezepte
RewriteRule ^rezepte\.php$ http://www.bla.de/cocktails/rezepte [L,R=301]
RewriteCond %{THE_REQUEST} /index\.php\?site=rezepte
RewriteCond %{QUERY_STRING} ^site=rezepte$
RewriteRule ^index\.php$ http://www.bla.de/cocktails/rezepte? [L,R=301]
### rezepte/name
RewriteCond %{THE_REQUEST} /index\.php\?site=rezepte&id=
RewriteCond %{QUERY_STRING} ^site=rezepte&id=([a-zA-Z0-9-_,]+)$
#RewriteRule ^index\.php$ http://www.bla.de/cocktails/rezepte/%1? [L,R=301]
RewriteRule ^rezepte/([a-zA-Z0-9-_,]+)$ index.php?site=rezepte&id=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cocktails/index.php?site=$1 [L]
So, what I posted makes:
index.php?site=recipe to /recipe
and if I uncomment
#RewriteRule ^index\.php$ http://www.bla.de/cocktails/rezepte/%1? [L,R=301]
it also redirects
index.php?site=recipes&id=2451 to recipes/2451
but I get an error 404.
If I comment this line out, the url is index.php?site=recipe&id=2451 but the content is displayed properly. Does someone has an idea whats wrong?
Best regards!