Currently, I have a webshop using http and https. For SEO in Google I try to split the webshop into a part using http and important data transfer using https. Pages like account, login and cart must be using https to secure data.
The webshop is divided in 3 categories: webshop, customer service and repair centre. With .htaccess I control the url by rewriting them into
http://www.site.com/webshop/~ or
http://www.site.com/customer-service/~ or
http://www.site.com/repair-centre/~
.htaccess:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA]
Important to know is that the index.php is controlling the rewrite instead of .htaccess:
PHP Code:
$aController = array_values( array_diff( explode('/', $_SERVER['REQUEST_URI']), explode('/', $_SERVER['SCRIPT_NAME'])));
if (isset($aController[0])) {
$sQueryI = "SELECT * FROM vvs_core_navigatie WHERE slug = '".mysql_real_escape_string($aController[0])."'";
if (!$sResultI = mysql_query($sQueryI)) {
echo getError('sQueryI', $paginaNaam);
} else {
if (mysql_num_rows($sResultI) == 1) {
$objI = mysql_fetch_assoc($sResultI);
if ($objI['ptype'] == 'p') {
$setPage = 'dir_content/frontpage.php';
} elseif ($objI['ptype'] == 'c') {
$setPage = 'dir_content/pagina.php';
}
} else {
header('Location: /');
}
}
}
What I want is to force https for the pages:
- site.com/??/account/
- site.com/??/account/log-in/
- site.com/??/cart/
- site.com/??/ordering/
On the place of ?? must be one of the three categories (webshop, customer service and repair centre), but this is dynamic and the pages are not fixed with a category.
The remaining pages must be forced to stay at http (no https).
What I have already tried is to modify my .htaccess:
Code:
# OLD SITUATION
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^(.*)$ index.php/$1 [QSA]
# force https for all URLs in /~/account/
RewriteCond %{HTTPS} = off
RewriteRule ^/(.*)/account/ https://%{HTTP_HOST}/$1/account/ [R=301,L]
# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
# force http for all other URLs that are not in /~/account/
RewriteCond %{HTTPS} = on
RewriteCond %{REQUEST_URI} !^/(.*)/account/
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# your other rules here, e.g.:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
The .htaccess code gives an error on the webshop.
Can someone help me with this problem, please?