IThoemmi IThoemmi - 2 months ago 10
Apache Configuration Question

htaccess Rewrite Cond to remove string from URL

i have some problems with links to my website.
For example:

http://example.com/service/www.blabla.de

I want to remove the string "www.blabla.de" via htaccess.
Can everybody help me?

It is possible that after "www.blabla.de" comes a query string for example:
http://example.com/service/www.blabla.de?query=test

The string must be in the URL.

Thank you

Answer

You can use this redirect rule in site root .htaccess:

RewriteEngine On

RewriteRule ^(service)/www\.blabla\.de/?$ /$1? [L,NC,R=301]

? at the end of target URI will strip off previous query string.

Comments