htaccess在购物车中无法正常工作


htaccess is not working as wanted in shopping cart

好吧,我正在制作一个购物车系统。

我的根文件夹中有.htaccess文件,其中包含以下代码:

RewriteEngine On
RewriteRule ^product/([^/.]+)/?$ product.php?code=$1 [L]
RewriteRule ^AnotherPage/([^/.]+)/?$ AnotehrPage.php?code=$1 [L]

有些页面我需要有查询字符串,例如添加到购物车页面。如果他们点击产品页面上的添加到购物车按钮,它会像这样重定向他们:

http://www.example.com/cart.php?action=add&code=ProductCode

当产品被添加到购物车中时,我再次将他们重定向到cart.php页面,在那里他们可以看到他们的产品被添加在购物车中。

出于某种原因,我还在结账页面中使用了查询字符串。

现在我想要的是,如何在.htaccess文件中编写规则和条件,以便查询字符串在不影响SEO功能和/或SEO URL的情况下工作。

SEO友好的URL只适用于静态页面,如显示产品详细信息、关于我们、联系我们等,动态页面将有查询字符串。

任何帮助都将不胜感激。提前谢谢。

以下是我试图解决的链接,但没有成功:https://stackoverflow.com/a/14308411/3514160

编辑1:以下是我迄今为止尝试过的完整htaccess:

RewriteEngine On
RewriteRule ^product/([^/.]+)/?$ product.php?code=$1 [L]
RewriteRule ^AnotherPage/([^/.]+)/?$ AnotehrPage.php?code=$1 [L]
RewriteCond %{QUERY_STRING} ^action=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &code=([^&]+) [NC]
RewriteRule ^cart'.php/([^/]+/[^/]+)$ http://www.example.com/cart.php/$1/%1/? [R,L]

编辑2:Product.php页面:

<?php
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
require_once 'Classes/class.Validation.php';
$validate = new Validation('benef8w7_ecommerce');
$code = substr($_SERVER["REQUEST_URI"], strrpos($_SERVER["REQUEST_URI"], '/') + 1);
$name = $amount = $desc = $specs = $return = $ship = $tncs = $qnty = "";
$metaKeyWords = $metaDescription = "";
$q = "SELECT * FROM products WHERE ProdCode = '".$code."' ";
if ( $validate->Query( $q ) == TRUE ) {
    if ( $validate->NumRows() >= 1 ) {
        while ( $row = $validate->FetchAllDatas() ) {
            $name = $row['ProdName'];
            $amount = $row['ProdRate'];
            $desc = $row['ProdDescription'];
            $specs = $row['ProdSpecifications'];
            $return = $row['ProdReturnCancellation'];
            $ship = $row['ProdShippingDelivery'];
            $tncs = $row['ProdTermsConditions'];
            $qnty = $row['ProdTotalQuantity'];
            $metaKeyWords = $row["ProdMetaKeyWords"];
            $metaDescription = $row["ProdMetaDescription"];
        }
    }
}
?>
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
<head>
    <title>Benefit Square - Product</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="keywords" content="<?php echo $metaKeyWords; ?>">
    <meta name="description" content="<?php echo $metaDescription; ?>">
    <link rel="icon" type="image/x-icon" href="//www.benefitsquare.com/nbs/images/bs-favicon.png">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/jquery.fancybox-1.3.4.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/jquery.custom-scrollbar.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/owl.carousel.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/style.css">
    <link href="css/font-awesome.min.css" rel="stylesheet">
</head>
<body>
    <!--wide layout-->
    <div class="wide_layout relative w_xs_auto">
        <!--markup header-->
        <?php require_once 'Includes/websiteNav.php'; ?>
        <div style="margin-top: -20px;"></div>
        <section class="breadcrumbs wide_layout relative w_xs_auto m_bottom_20">
            <div class="container">
                <ul class="horizontal_list clearfix bc_list f_size_medium">
                    <li class="m_right_10 current">
                        <a href="//www.benefitsquare.com/nbs/" class="default_t_color">
                            Home<i class="fa fa-angle-right d_inline_middle m_left_10"></i>
                        </a>
                    </li>
                    <li class="m_right_10">
                        <a href="//www.benefitsquare.com/nbs/products.php" class="default_t_color">
                            Products<i class="fa fa-angle-right d_inline_middle m_left_10"></i>
                        </a>
                    </li>
                    <li>
                        <?php echo $name . " - " . $code; ?>
                    </li>
                </ul>
            </div>
        </section>

        <!--content-->
        <div class="page_content">
            <div class="container">
                <div class="row clearfix">
                    <section class="col-lg-12 col-md-12 col-sm-12 m_xs_bottom_30">
                        <div class="clearfix m_bottom_15 t_xs_align_c">
                            <h2 class="color_dark fw_medium m_bottom_10"><?php echo $name; ?></h2>
                        </div>
                    </section>
                    <!--left content column-->
                    <section class="col-lg-9 col-md-9 col-sm-9 m_xs_bottom_30">
                        <div class="clearfix m_bottom_30 t_xs_align_c">
                            <div class="photoframe type_2 shadow r_corners f_left f_sm_none d_xs_inline_b product_single_preview relative m_right_30 m_bottom_5 m_sm_bottom_20 m_xs_right_0 w_mxs_full">
                                <div class="relative d_inline_b m_bottom_10 qv_preview d_xs_block">
                                    <img id="zoom_image" src="//www.benefitsquare.com/nbs/images/Products/<?php echo $code ?>.jpg" data-big="images/Products/<?php echo $code ?>.jpg" class="tr_all_hover" alt="<?php echo $name; ?>" height="438" width="438">
                                    <a href="//www.benefitsquare.com/nbs/images/Products/<?php echo $code; ?>.jpg" class="d_block button_type_5 r_corners tr_all_hover box_s_none color_light p_hr_0">
                                        <i class="fa fa-expand"></i>
                                    </a>
                                </div>
                                <!--carousel-->
                                <!-- <div class="relative qv_carousel_wrap">
                                    <button class="button_type_11 bg_light_color_1 t_align_c f_size_ex_large bg_cs_hover r_corners d_inline_middle bg_tr tr_all_hover qv_btn_single_prev">
                                        <i class="fa fa-angle-left "></i>
                                    </button>
                                    <ul class="qv_carousel_single d_inline_middle maddy">
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                        <a href="#" data-image="images/Products/<?php echo $code ?>.jpg" data-zoom-image="images/Products/<?php echo $code ?>.jpg">
                                            <img src="images/Products/<?php echo $code ?>.jpg" alt="<?php echo $name; ?>" height="110" width="110">
                                        </a>
                                    </ul>
                                    <button class="button_type_11 bg_light_color_1 t_align_c f_size_ex_large bg_cs_hover r_corners d_inline_middle bg_tr tr_all_hover qv_btn_single_next">
                                        <i class="fa fa-angle-right "></i>
                                    </button>
                                </div> -->
                            </div>
                            <div class="p_top_10 t_xs_align_l">
                                <!--description-->
                                <!-- <h2 class="color_dark fw_medium m_bottom_10"><?php echo $name; ?></h2> -->
                                <hr class="m_bottom_10 divider_type_3">
                                <table class="description_table m_bottom_10">
                                    <tr>
                                        <td>Availability:</td>
                                        <td>
                                            <?php if($qnty >= 1): ?>
                                                <span class="color_green">in stock</span> <?php echo $qnty . ' items(s)'; ?>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Product Code:</td>
                                        <td><?php echo $code; ?></td>
                                    </tr>
                                </table>
                                <hr class="divider_type_3 m_bottom_10">
                                <p class="m_bottom_10"><?php echo $desc; ?></p>
                                <hr class="divider_type_3 m_bottom_15">
                                <div class="m_bottom_15">
                                    <span class="v_align_b f_size_big m_left_5 scheme_color fw_medium">Rs.: <?php echo $amount; ?></span>
                                </div>
                                <div class="m_bottom_20">
                                    <!-- <a href="cart.php?action=add&code=<?php //echo $code; ?>" class="button_type_12 r_corners bg_scheme_color color_light tr_delay_hover d_inline_b f_size_large">Add to Cart</a> -->
                                    <a href="http://www.benefitsquare.com/nbs/cart/add/<?php echo $code; ?>" class="button_type_4 bg_scheme_color r_corners tr_all_hover color_light mw_0 m_bottom_15">Add to Cart</a>
                                </div>
                            </div>
                        </div>
                        <!--tabs-->
                        <div class="accordion m_bottom_45">
                            <?php if (!empty($specs)): ?>
                                <div class="accordion_item r_corners shadow wrapper m_bottom_5">
                                    <h3 class="color_light active a_title relative tr_all_hover">
                                        Specifications
                                        <span class="minus_icon tr_all_hover">-</span>
                                        <span class="plus_icon tr_all_hover">+</span>
                                    </h3>
                                    <div class="bg_light_color_3 a_content">
                                        <p class="m_bottom_10">
                                            <?php echo $specs; ?>
                                        </p>
                                    </div>
                                </div>
                            <?php endif; ?>
                            <?php if (!empty($return)): ?>
                                <div class="accordion_item r_corners shadow wrapper m_bottom_5">
                                    <h3 class="bg_light_color_1 color_dark a_title relative tr_all_hover">
                                        Return And Cancellation
                                        <span class="minus_icon tr_all_hover">-</span>
                                        <span class="plus_icon tr_all_hover">+</span>
                                    </h3>
                                    <div class="bg_light_color_3 a_content">
                                        <p class="m_bottom_10">
                                            <?php echo $return; ?>
                                        </p>
                                    </div>
                                </div>
                            <?php endif; ?>
                            <?php if (!empty($ship)): ?>
                                <div class="accordion_item r_corners shadow wrapper m_bottom_5">
                                    <h3 class="bg_light_color_1 color_dark a_title relative tr_all_hover">
                                        Shipping
                                        <span class="minus_icon tr_all_hover">-</span>
                                        <span class="plus_icon tr_all_hover">+</span>
                                    </h3>
                                    <div class="bg_light_color_3 a_content">
                                        <p class="m_bottom_10">
                                            <?php echo $ship; ?>
                                        </p>
                                    </div>
                                </div>
                            <?php endif; ?>
                            <?php if (!empty($tncs)): ?>
                                <div class="accordion_item r_corners shadow wrapper m_bottom_5">
                                    <h3 class="bg_light_color_1 color_dark a_title relative tr_all_hover">
                                        Terms And Conditions
                                        <span class="minus_icon tr_all_hover">-</span>
                                        <span class="plus_icon tr_all_hover">+</span>
                                    </h3>
                                    <div class="bg_light_color_3 a_content">
                                        <p class="m_bottom_10">
                                            <?php echo $tncs; ?>
                                        </p>
                                    </div>
                                </div>
                            <?php endif; ?>
                        </div>
                        <hr class="divider_type_3 m_bottom_15">
                    </section>
                    <!--right column-->
                    <aside class="col-lg-3 col-md-3 col-sm-3">
                        <?php
                        $q = "SELECT p.*, b.* FROM products p, beneficiaries b WHERE p.BenCode = b.BenCode AND p.ProdCode = '".$code."'";
                        $validate->Query($q);
                        if ($validate->NumRows() >= 1) {
                            while ($row = $validate->FetchAllDatas()) {
                                $fileName = $row["BenCode"].".jpg";
                                $filePath = "http://www.benefitsquare.com/nbs/images/Beneficiary/".$fileName;
                                $msg = "The File Does not exts";
                                echo '
                                <figure class="widget shadow r_corners wrapper m_bottom_15">
                                    <figcaption>
                                        <h3 class="color_light t_align_c">About Beneficiary</h3>
                                    </figcaption>
                                    <div class="widget_content t_align_c">
                                        <div class="circle wrapper team_photo d_inline_b m_bottom_15">';
                                            if ( @getimagesize($filePath)) {                                                
                                                echo '<img src="//www.benefitsquare.com/nbs/images/Beneficiary/'.$row["BenCode"].'.jpg" alt="'.$row["BenFullName"].'">';
                                            } else {
                                                echo '<img src="//placehold.it/200x200" alt="">';
                                            }
                                            echo '
                                        </div>
                                        <h4 class="fw_medium color_dark">
                                            <a href="beneficiary.php?code='.$row["BenCode"].'" class="color_dark">'.$row["BenFullName"].'</a>
                                        </h4>
                                        <p class="color_dark m_bottom_10">'.$row["BenCode"].'</p>
                                        <p class="color_dark m_bottom_10">'.$row["BenCity"].', '.$row["BenState"].', '.$row["BenCountry"].'</p>
                                    </div>
                                </figure>
                                ';
                            }
                        }
                        ?>
                        <?php require_once 'PHP_Includes/CategoriesWidget.php'; ?>
                        <!--tags-->
                        <figure class="widget shadow r_corners wrapper m_bottom_30">
                            <figcaption>
                                <h3 class="color_light">Tags</h3>
                            </figcaption>
                            </div>
                        </figure>
                    </aside>
                </div>
            </div>
        </div>
        <!--markup footer-->
        <?php require_once 'Includes/websiteFooter.php'; ?>
    </div>
    <!--login popup-->
    <?php require_once 'Includes/CustomerLogin.php'; ?>
    <!--login popup-->
    <?php require_once 'Includes/CustomerRegistration.php'; ?>
</body>
</html>

cart.php

<?php
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
require_once 'Classes/class.Validation.php';
$validate = new Validation('benef8w7_ecommerce');
$code = "";
$sesionAmount = 0;
$amount = 0;
$code = substr($_SERVER["REQUEST_URI"], strrpos($_SERVER["REQUEST_URI"], '/') + 1);
if ( (isset($_GET["action"]) && $_GET["action"] == "add" ) && (isset($_GET["code"]) && $_GET["code"] != "" ) ) {
    if ( isset( $_SESSION['cart'][$code] ) && $_SESSION['cart'][$code] != "" ) {
        $_SESSION['cart'][$code]['quantity']++;
    } else {
        $q = "SELECT * FROM products WHERE ProdCode = '".$code."' ";
        $validate->Query( $q );
        if ( $validate->NumRows() >= 1 ) {
            while ( $row = $validate->FetchAllDatas() ) {
                $_SESSION['cart'][$row['ProdCode']] = array(
                    "quantity" => 1,
                    "rate" => $row['ProdRate']
                    );
                $_SESSION['cartAmt'] = $row['ProdRate'] * $_SESSION['cart'][$row['ProdCode']]['quantity'];
            }
        } else {
            echo '<br />No product fetched.<br />';
        }
    }
}

if ( isset( $_POST['btnSubmit'] ) ) {
    foreach ( $_POST['qnty'] as $key => $value ) {
        $_SESSION['cart'][$key]['quantity'] = $value;
        header("Location: cart.php");
    }
}
?>
<!DOCTYPE html>
<!--[if IE 9 ]><html class="ie9" lang="en"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
<head>
    <title>Benefit Sqaure - Cart</title>
    <!-- Meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="author" content="">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" type="image/x-icon" href="//www.benefitsquare.com/nbs/images/bs-favicon.png">
    <!--stylesheet include-->
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/flexslider.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/owl.carousel.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/owl.transitions.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/jquery.custom-scrollbar.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/style.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" media="all" href="//www.benefitsquare.com/nbs/StyleSheets/toastr.css">
    <style type="text/css">
        .ShowProds {
            display: none;
        }
        .ShowProds ul {
            border: 1px solid #000;
        }
        .ShowProds ul li {
            background: #fff;
            padding: 5px;
            border-bottom: 1px #eee solid;
        }
    </style>
</head>
<body>
    <!--boxed layout-->
    <div class="wide_layout relative w_xs_auto">
        <?php require_once 'Includes/websiteNav.php'; ?>
        <div class="page_content">
            <div class="container">
                <div class="row clearfix">
                    <section class="col-lg-9 col-md-9 col-sm-9 m_xs_bottom_30">
                        <h2 class="tt_uppercase color_dark m_bottom_25">Cart</h2>
                        <table class="table_type_4 responsive_table full_width r_corners wraper shadow t_align_l t_xs_align_c m_bottom_30">
                            <thead>
                                <tr class="f_size_large">
                                    <th>Product Image &amp; Name</th>
                                    <th>Product Code</th>
                                    <th>Price</th>
                                    <th>Quantity</th>
                                    <th>Subtotal</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <?php
                                    if ( isset( $_SESSION['cart'] ) && is_array( $_SESSION['cart'] ) && sizeOf( $_SESSION['cart'] ) > 0 ) {
                                        $total = 0;
                                        $subTotal = 0; $sbTotal = 0;
                                        $taxAmount = $tax = $totalTaxAmount = $taxAmt = 0;
                                        $cartWeightPerProduct = $totalCartWeight = $amtWeight = 0;
                                        $sql = "SELECT p.*, c.*, ws.* FROM products p, categories c, weight_shipping ws WHERE p.ProdCode IN (";
                                            foreach ( $_SESSION['cart'] as $id => $value ) {
                                                $sql .= '"'.$id.'",';
                                            }
                                            $sql = substr( $sql, 0, -1 ) . ") AND p.CatId = c.CatId AND ws.ProdId = p.ProdId";
if ($validate->Query($sql) == TRUE) {
    if ($validate->NumRows() >= 1) {
        while ( $row = $validate->FetchAllDatas() ) {
            echo '<tr>';
            echo '<td data-title="Product Image &amp; name" class="t_md_align_c"><img src="images/Products/'.$row['ProdCode'].'.jpg" alt="'.$row['ProdCode'].'" class="m_md_bottom_5 d_xs_block d_xs_centered" height="75" width="75"><a href="product.php?code='.$row['ProdCode'].'" class="d_inline_b m_left_5 color_dark">'.$row['ProdName'].'</a></td>';
            echo '<td data-title="SKU">'.$row['ProdCode'].'</td>';
            echo '<td data-title="Price"><p class="f_size_large color_dark">Rs. '.$row['ProdRate'].'</p></td>';
            echo '<td data-title="Quantity"><div class="clearfix quantity r_corners d_inline_middle f_size_medium color_dark m_bottom_10"><form action="cart.php" method="POST"><input type="number" max="99" min="0" name="qnty['.$row["ProdCode"].']" value="'.$_SESSION['cart'][$row['ProdCode']]['quantity'].'" class="f_left"><br /><button type="submit" name="btnSubmit" class="f_left"><span class="fa fa-refresh"></span></button></form><form action="removeProduct.php" method="POST"><input type="hidden" name="remove['.$row["ProdCode"].']" value="'.($row['ProdRate'] * $_SESSION['cart'][$row['ProdCode']]['quantity']).'"><button type="submit" name="btnRemove" class="f_right"><span class="fa fa-times"></span></button></form></div></td>';
            $sbTotal = $row['ProdRate'] * $_SESSION['cart'][$row['ProdCode']]['quantity'];
            $subTotal = $sbTotal;
            echo '<td data-title="Subtotal"><p class="f_size_large fw_medium scheme_color t_align_r">'.number_format($sbTotal, 2).'</p></td>';
            $total += $subTotal;
            $_SESSION['cartTotalAmount'] = $total;
            $tax = $row['CatTaxPercent'];
            $taxAmt = (($sbTotal * $tax ) / 100);
            $taxAmount += $taxAmt;
            $amt = 0;
            $cartWeightPerProduct = ($row['weight'] * $_SESSION['cart'][$row['ProdCode']]['quantity']);
            echo '</tr>';
            $totalCartWeight += $cartWeightPerProduct;
        }
        $totalTaxAmount += $taxAmount;
        $_SESSION['cartWeight'] = $totalCartWeight;
        if ( isset( $_SESSION['credits'] ) && $_SESSION['credits'] != "" ) {
            $cred = number_format( $_SESSION['credits'], 2 );           
        } else {
            $cred = number_format( 0, 2 );
        }
        $_SESSION['sessionTotalPayable'] = ( ($total + $totalTaxAmount) - $cred );
        //$_SESSION['Presentation']['TotalPayableAmount'] = number_format($_SESSION['sessionTotalPayable'], 2);
        $_SESSION['Presentation']['TotalPayableAmount'] = ( ($total + $totalTaxAmount) - $cred );
        if ( isset( $_SESSION['sessionTotalPayable'] ) ) {
            $amt = $_SESSION['sessionTotalPayable'];
        } else {
            $amt = "Rs. 0";
        }
        echo '<tr><td colspan="4"><p class="fw_medium f_size_large t_align_r t_xs_align_c">Cart Total:</p></td><td colspan="1"><p class="fw_medium f_size_large color_dark t_align_r">'.number_format($total, 2).'</p></td></tr>';
        echo '<tr><td colspan="4"><p class="f_size_large t_align_r t_xs_align_c">Taxes:</p></td><td colspan="1"><p class="f_size_large color_dark t_align_r">'. number_format($totalTaxAmount, 2) .'</p></td></tr>';
        echo '<tr><td colspan="4"><p class="f_size_large t_align_r t_xs_align_c">Shipment Fee </p></td><td colspan="1"><p class="f_size_large color_dark t_align_r" id="amt"><button id="amoutn" data-popup="#clickMeForGettingShippingAmount" class="tr_delay_hover r_corners button_type_16 f_size_medium bg_scheme_color color_light m_xs_bottom_5">Estimate</button></p></td></tr>';
        echo '<tr><td colspan="4"><p class="f_size_large t_align_r t_xs_align_c">Applied Store Credits:</p></td><td colspan="1"><p class="f_size_large color_dark t_align_r">( - ) '.$cred.'</p></td></tr>';
        // echo '<tr><td colspan="4"><p class="fw_medium f_size_large t_align_r t_xs_align_c">Total Payable Amount:</p></td><td colspan="1"><p class="fw_medium f_size_large color_dark t_align_r">'.number_format( ( ($total + $totalTaxAmount) - $cred), 2).'</p></td></tr>';
        echo '<tr><td colspan="4"><p class="fw_medium f_size_large t_align_r t_xs_align_c">Total Payable Amount:</p></td><td colspan="1"><p class="fw_medium f_size_large color_dark t_align_r">'.number_format( ( ($total + $totalTaxAmount) - $cred ), 2).'</p></td></tr>';
        echo '<tr><td colspan="4"><div id="chckOutBtn"><button class="f_right tr_delay_hover r_corners button_type_16 f_size_medium bg_scheme_color color_light m_xs_bottom_5">Proceed to Checkout</button></div></td><td colspan="1"><p class="fw_medium f_size_large color_dark t_align_r"><a href="EmptyCart.php">Empty Cart</a></p></td></tr>';
    }
}
} else {
    unset($_SESSION['sessionTotalPayable']);
    unset($_SESSION['credits']);
    unset($_SESSION['Presentation']['TotalPayableAmount']);
}
?>
</tr>
</tbody>
</table>
<?php if (isset($_SESSION['cart'])): ?>
    <p class="f_size_large t_align_r t_xs_align_c m_bottom_20">Apply Store Credits: <a href="http://www.benefitsquare.com/nbs/StoreCredits.php">Click Here</a></p>
<?php endif; ?>
</section>
<aside class="col-lg-3 col-md-3 col-sm-3">
    <?php require_once 'PHP_Includes/CategoriesWidget.php'; ?>
</aside>
</div>
</div>
</div>
<!--markup footer-->
<?php require_once 'Includes/websiteFooter.php'; ?>
<!-- Calculate shipping pop-up -->
<div class="popup_wrap d_none" id="clickMeForGettingShippingAmount">
    <section class="popup r_corners shadow">
        <button class="bg_tr color_dark tr_all_hover text_cs_hover close f_size_large"><i class="fa fa-times"></i></button>
        <div class="clearfix">
            <div class="custom_scrollbar">
                <h2 class="tt_uppercase color_dark m_bottom_25 t_align_c">Calculate your shipping charge</h2>
                <p class="m_bottom_25" style="color: #f00;">Note: This is will be added to your cart once you register your region on the checkout page. This is just for your estimation.</p>
                <form id="contactform">
                    <ul>
                        <li class="clearfix m_bottom_15">
                            <div class="f_left half_column">
                                <label for="cf_name" class="required d_inline_b m_bottom_5">Your Zone:</label>
                            </div>
                        </li>
                        <li class="m_bottom_50">
                            <select name="selectZone" id="zone" class="full_width r_corners">
                                <?php
                                $q = "SELECT * FROM shipping_zones ORDER BY ZoneName";
                                $validate->Query($q);
                                while ($row = $validate->FetchAllDatas() ) {
                                    echo '<option value="'.$row['ZoneId'].'">'.$row['ZoneName'].'</option>';
                                }
                                ?>
                            </select>
                        </li>
                        <li>
                            <input type="submit" id="check" name="btnCheckShipping" value="Done" class="full_width button_type_4 bg_light_color_2 r_corners mw_0 tr_all_hover color_dark" />
                        </li>
                    </ul>
                </form>
                <div class="m_bottom_50"></div>
                <h2 class="tt_uppercase t_align_c color_dark m_bottom_25">Your Shipping Amount Is:</h2>
                <?php
                /*if (isset($_SESSION['TotalWeight']) && $_SESSION['TotalWeight'] != "") {
                    $weightAmnt = $_SESSION['TotalWeight'];
                } else {
                    $weightAmnt = 0;
                }*/
                ?>
                <h2 class="t_align_c color_dark m_bottom_25" id="totAm"><?php echo $amtWeight; ?></h2>
            </div>
        </div>
    </section>
</div>
</div>
</body>
</html>

将这些规则放在.htaccess:的顶部

RewriteEngine On
RewriteBase /nbs/
RewriteCond %{THE_REQUEST} /cart'.php'?action=([^'s&]+)&code=([^'s&]+) [NC]
RewriteRule ^ cart/%1/%2? [R=302,L,NE]
RewriteRule ^cart/([^/.]+)/([^/.]+)/?$ cart.php?action=$1&code=$2 [L,QSA,NC]
RewriteRule ^product/([^/.]+)/?$ product.php?code=$1 [L,QSA,NC]
RewriteRule ^AnotherPage/([^/.]+)/?$ AnotehrPage.php?code=$1 [L,QSA,NC]