0

I'm having a hard time figuring out how to re-direct multiple portions of a site to the https:// version.

What I have so far does work, it just randomly throws in an extra '?' sometimes?

<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

# https: redirect to safe CP url
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} system 
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

# https: redirect to safe Product url
RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} /product/
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

# https: redirect to safe Checkout url
RewriteCond %{SERVER_PORT} 80
RewriteCond %{QUERY_STRING} /checkout/
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]

# Force www:
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteRule ^(.*)$ http://www\.%1/$1 [R=301,L]
</ifmodule>

This does work, partially. Like I said, sometimes when a re-drecit happens an extra '?' is thrown in and I can't seem to figure out why.

So if I go to

http://www.mysite.com/product/some-product

for example, it will re-direct to

https://www.mysite.com/?/product/some-product

If any additional info is needed let me know! And thanks for any input in advance!! :)

1

On line 11, change:

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

to

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

And see if that works. According to https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html, you only need to use your entry for forced query strings on hosts such as GoDaddy. However, if that's the case, you may be stuck with it.

| improve this answer | |
  • I did try that and unfortunately it didn't work. – shparkison Aug 1 '14 at 0:15

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.