I try to rewrite any URL if a special parameter exists.
So that this happens:
From: www.example.com/somepage/someother/?entryValue=somevalue
To: www.example.com/somepage/someother/?product=test&special=12345ls&linkSource=website
I tried to following, but it doesnt work as expected:
This code adds var/www/*
instead of the link
www.example.com/var/www/web6/htdocs/example.com/index.php/*
RewriteCond %{QUERY_STRING} (^|&)entryValue=somevalue`
RewriteRule ^(.*)$ $1/?product=test&special=12345ls&linkSource=website [L,R]
This code removes the path:
RewriteCond %{QUERY_STRING} (^|&)entryValue=somevalue
RewriteRule ^(.*)$ /?product=test&special=12345ls&linkSource=website [L,R]
How can I make it work?
CodePudding user response:
RewriteCond %{QUERY_STRING} (^|&)entryValue=somevalue RewriteRule ^(.*)$ $1/?product=test&special=12345ls&linkSource=website [L,R]
You need to include a slash prefix at the start of the substitution string. Like this:
RewriteRule ^(.*)$ /$1/?product=test&special=12345ls&linkSource=website [L,R]
Without the slash prefix (the URL-path matched by the RewriteRule
pattern does not include a slash prefix) it is seen as relative and the directory-prefix (ie. /var/www/...
) will be added back and result in the malformed redirect you are seeing.