Question

I'm hosted on mediatemple DV 4.0 server and use the following lines in my htaccess file (rewrite rules for the CMS)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]

it works well but when I'm trying to do a 301 redirect to point the old page to a new address it adds some unnecessary stuff into the url, for instance:

?id=locations-maryland

How do I modify the rewrite rule to keep the same functionality but remove the last part which basically makes the 301 redirect pointless as the CMS couldn't not find any page with this spammy url.

It happens only on mediatemple I heard something about adding/removing an additional question mark somewhere but have not enough knowledge to resolve it by myself.

Was it helpful?

Solution

Add a ? to the end of the redirect target. Example:

Redirect /something/ /something/else/? 

or if you're using mod_rewrite:

RewriteRule ^/?something/(.*)$ /something/else/$1? [L,R=301]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top