Reputation: 11
I have this structure in my site:
/
/portal <--(WordPress Folder)
when someone enters www.example.com it should redirect to https://www.example.com/portal but shouldn't show portal, so, address bar should look like: https://www.example.com
As this is a WordPress + Woocomerce site I also need some redirects like:
http://www.example.com/carrito to https://www.example.com/carrito
Problem is that at this moment, when I input http://www.example.com/carrito it changes adress bar to https://www.example.com/portal/carrito
currently I have this .htaccess files:
/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?
example.com$
RewriteCond %{REQUEST_URI} !^/portal/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /portal/$1
RewriteCond %{HTTP_HOST} ^(www.)?
example.com$
RewriteRule ^(/)?$ portal/index.php [L]
</IfModule>
/portal/.htaccess
RewriteEngine On
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L]
# RewriteCond %{SERVER_PORT} ^80$
# RewriteRule ^(.*)$ https://%{SERVER_NAME}/%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Upvotes: 1
Views: 68
Reputation: 1624
Try to update the code in htaccess file, I have mentioned in below,
RewriteEngine On
# If we receive a forwarded http request from a proxy...
RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR]
# ...or just a plain old http request directly from the client
RewriteCond %{HTTP:X-Forwarded-Proto} =""
RewriteCond %{HTTPS} !=on
# Redirect to https version
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L]
# RewriteCond %{SERVER_PORT} ^80$
# RewriteRule ^(.*)$ https://%{SERVER_NAME}/%{REQUEST_URI} [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Follow the link for get the more details- https://in.godaddy.com/help/redirect-http-to-https-for-wordpress-on-linux-27904
Upvotes: 1