Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2013, 09:08 PM   PM User | #1
lau87
New Coder

 
Join Date: Jul 2009
Posts: 20
Thanks: 2
Thanked 0 Times in 0 Posts
lau87 is an unknown quantity at this point
Force particular pages to https

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_valuesarray_diffexplode('/'$_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?
lau87 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:05 PM.


Advertisement
Log in to turn off these ads.