2016-04-23 28 views
1

我现在得到的工作是这样的:

 webshop/index.php?page=home

改写为:

webshop/home

但现在我想有以下链接:

webshop/account/login

我认为它应该与我得到的代码一起工作,但事实并非如此。

我得到了什么是下面的PHP代码:

<?php 
if (isset($_GET['page'])) { 
$page = $_GET['page'];  
} else {      
    $page = 'home';  
} 
if (strpos($page, '/') !== false || !file_exists("pages/$page.php")) { 
    $page = 'error';            
} 
include ("pages/$page.php");   
?> 

,这是我的.htaccess文件:

Options +FollowSymLinks -MultiViews 
RewriteEngine On 

RewriteCond %{THE_REQUEST} /index\.php [NC] 
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^webshop/([^/]*)$ /webshop/?page=$1 [L] 
+0

什么问题到底是什么? – starkeen

+0

我想订购页面的子文件夹,如:帐户容器登录注册等。我想要的链接是网上商店/帐户/登录 – Kevin

回答

1

试试这个,你可以返回多PARAMS

Options +FollowSymLinks -MultiViews 
RewriteEngine On 

RewriteBase /webshop/ 

RewriteCond %{THE_REQUEST} /index\.php [NC] 
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} ^/([^/]+)/?([^/]*)? [NC] 
RewriteRule .* index.php?page=%1&route=%2 [L]