2016-06-17 33 views
2

我有一個像爾康 - 如何隱藏獲得URL參數應用與的.htaccess

localhost/case?id=name 

如何隱藏的ID部分,而不使用htaccess的路由,只是一個url顯示:

localhost/case/name 

PS框架爾康

htaccess的有:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] 
</IfModule> 
+2

爲什麼你不想使用路由? – Juri

+0

@Juri我想要使用的.htaccess,但如果它不工作,我會使用路由器 – th3King

回答

0

試試這個:

#if our requested file isn't a dir, and isn't a file, and isn't a symbolic link 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-l 
#then skip our next rule below 
RewriteRule .* - [S=1] 
#since we got here, the file exists, so don't rewrite it, skip the next two rules 
RewriteRule .* - [S=2] 
#these two rules are bound to our condition i.e. if the link is broken 
RewriteRule ^case/([^/]*)$ index.php?_url=/case&id=$1 [QSA,L] 
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] 
#end of our two rules which would be skipped if our condition was false 
+0

謝謝你,它的工作原理 – th3King

0

試試這個:

RewriteEngine On 
RewriteRule ^case/([^/]*)$ /case?id=$1 [L] 
+0

THX,但它不工作:( – th3King