I'm trying to redirect one directory on my site to https. The directory is not really a directory at all because the site's dynamic. I'm using ExpressionEngine as the CMS.
I already have a few lines in my .htaccess file to remove the index.php ExpressionEngine adds to all of its urls.
Here's what I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://mysite.com/store/$1 [R,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
When I visit, http://mysite.com/store/ , it returns https://mysite.com/store/store/ .
I think it might have to do with the following:
RewriteRule ^(.*)$ /index.php?/$1 [L]
The above line has a question mark after the index.php because I was getting a "No input file" error, and that was the recommended fix.
Any thoughts?
This line here:
RewriteCond %{REQUEST_URI} store
Should have a !
in front of "store":
RewriteCond %{REQUEST_URI} !store
because you don't want it to redirect if the URI is already /store
.
Edited the line:
RewriteRule ^(.*)$ https://mysite.com/store/$1 [R,L]
to read:
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
Now it works. Here's the full code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} store
RewriteRule ^(.*)$ https://mysite.com/$1 [R,L]
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.