8

First time this has happend to me and I can't figure out how to fix my 301 redirects. The redirect is appending the rule to the end of destination/new url:

Redirect 301 /products.htm http//www.domain.com/products/

Redirects to:

http://www.domain.com/products/?/products.htm

The site is on a MediaTemple (dv) 4.0. My .htaccess file is:

## BEGIN Expression Engine Rewrite

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]

# END Expression Engine Rewrite

# Redirect to www
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]


#
# Old site URL 301 Redirects
#

Redirect 301 /products.htm http://www.domain.com/products/
# plus many more...

UPDATE:

Just wanted to add what I've tried with no success:

`$config['uri_protocol']    = 'AUTO'; // tried all 5 options. nothing seemed to change`

I tried appending ? to the end of the redirect, which removed the appending rule, but kept the ?:

Redirect 301 /products.htm http://www.domain.com/products/?

I have successfully setup redirects before in EE1, and referenced a site & noticed the rewrite rule for removing the index.php file didn't have the ? at the end. Is this something specific to EE2 or the server envirnoment as when I remove that I get the no input file specified error:

# EE1
RewriteRule ^(.*)$ /index.php/$1 [L]
3
  • 2
    I've always found this issue when using .htaccess to remove index.php from EE URLS and then adding additional redirects. Never been able to solve it. Would love to see an answer here. – Derek Hogue Jan 22 '13 at 13:12
  • Added more context & what I've tried so far with no success. – Siebird Jan 22 '13 at 13:37
  • 1
    It's PHP running as a CGI module that requires the ? in the rewrite. – Derek Hogue Jan 22 '13 at 13:51
9

Thanks for nudge Derek. I was totally unaware that the site was running as a FastCGI process. This is the default with (mt) dv 4.0 & Plesk 11.0.9 when creating new hosts. Which maybe explains other user's issues with removing index.php at MediaTemple

I switched it back to Apache and removed the ? from the rewrite rule and the redirects are working properly.

RewriteRule ^(.*)$ /index.php/$1 [L]

To change PHP support at MediaTemple (dv) 4.0, go to the domain in Plesk. Open the Control panel and click the website & domains tab. Click the advanced operations then Website Scription & Security. Select Apache from the PHP select menu.

Update For Fix w/PHP running as CGI process – 1/31/13

If PHP is running as CGI process and the query string ? is appended to the URL, you can use this rewrite rule instead of redirect:

RewriteRule ^old-url?/?$ http://www.website.com/new-url [L,R=301]

See comment below for reference article

2
  • Glad you sorted this, great tips ... would love to hear if someone can solve the issue when PHP as CGI is enabled (if it's even possible). – Derek Hogue Jan 23 '13 at 1:07
  • Derek, I just found a solution for this and it's working on a client site of mine. Updated answer for posterity: stemkoski.com/… – Siebird Jan 31 '13 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.