2015-05-13 144 views
0

我已经重写URL在我的网站的.htaccesshtaccess的URL重写URL multple

的index.php

$op = $_GET['op']; 

switch ($op) { 

    case "src": 
     include("src.php"); 
    break; 

    case "dts": 
     include ("dts.php"); 
    break; 

    default: 
     include("home.php"); 
    break; 
} 

链接问题重写

index.php?op=src 
index.php?op=dts&idric=20&sp=2 

的.htaccess

Options +FollowSymLinks 
RewriteEngine on 

RewriteRule \.(css|jpe?g|gif|png|js|ico)$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 

RewriteRule ^(.*)/$ index.php?op=$1 [L,QSA] 
RewriteRule ^(.*)/idric/(.*)/sp/(.*)/$ index.php?op=$1&idric=$2&sp=$3 [L,QSA] 

如果我写第一个lin k www.mysite.com/src/它显示正确的页面(src.php), 但如果我写第二个网址www.mysite.com/dts/idric/20/sp/2/它显示默认页面( home.php)。

有人能告诉我如何解决? 谢谢

+0

你有这样的事情在你的代码'$ OP = $ _GET [ '运'];'? –

回答

1

RewriteCond只适用于非常接下来RewriteRule。最后一条规则被前一条规则覆盖。

让你的规则是这样的:

​​
+0

不幸的是,这种方式没有任何作用,甚至没有第一个链接mysite.com/src/ – Gus

+0

在我的Apache'localhost/dts/idric/20/sp/2 /'上给这些规则给了'$ _GET ['op'] ''作为'dts'和''localhost/src /'作为'src'给出了你的错误。你是否复制/粘贴如图所示?还有其他规则吗? – anubhava

+0

其实我的测试网址是这个localhost/test/src /和localhost/test/dts/idric/20/sp/2/ – Gus