문제

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.

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top