2

I've got a somewhat standard .htaccess for removing index.php from my EE1 URLs:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{QUERY_STRING} ^(utm_source=.*)
RewriteRule ^(.*)$ /index.php?/ [L,PT]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ /index.php?/$1&%1 [L]

What I need to do is redirect calls to a subfolder (/store) to a new subdomain (store.example.com). So I added this line at the top:

Redirect 301 /store http://store.example.com/

Unfortunately, the end result is that I get redirected to http://store.example.com//?/store/

I've tried a few variations, such as moving the line to the bottom, but nothing worked properly.

How can I do a 301 redirect (using .htaccess) without including the extra /?/store/ bit at the end?

  • I'll see if I can whip up some htaccess magic for you in a few hours, not at the office yet. Pretty sure your fist parameter needs regex expression start and end delimiters. – jrothafer Sep 4 '15 at 12:33
  • Or actually you might need a redirect match rule, not just a redirect. Some combo of all the crap I just said. – jrothafer Sep 4 '15 at 12:35
1

Try a RedirectMatch rule and see what you get:

RedirectMatch 301 ^/store/?$ http://store.example.com
  • Miniscule improvement - now I get redirected to http://store.example.com/?/store/ (with just the one forward slash instead of two). – Sandwich Sep 7 '15 at 9:05
  • I hate to say it, but there is a great chance this rule is being modified by another. Cascading htaccess rules can be a pain. Would it be reasonable to post your entire htaccess file with your domain redacted? – jrothafer Sep 7 '15 at 20:31
  • Like, stuff like what your redirect base is, your index.php removal is, all affects how we should go about this rule set. Including any other redirect rules. I know, htaccess is a pain, but I can probably help you if I see the whole thing. If I can't, next I'll be bugging you about your environment. – jrothafer Sep 7 '15 at 20:47
  • What I posted in the OP is my entire .htaccess. :p – Sandwich Sep 16 '15 at 13:15
1

This is what we use to redirect a directory to a subdomain

RewriteRule ^trade* http://trade.domain.com/    [R=301,L]

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.