Phalcon - 如何使用.htaccess隐藏URL中的参数

时间:2016-06-17 15:48:03

标签: .htaccess url-rewriting phalcon

我有一个像

的网址
localhost/case?id=name

如何使用htaccess隐藏id部分而不使用路由,只需显示:

localhost/case/name

P.S。框架phalcon

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 个答案:

答案 0 :(得分:0)

尝试一下:

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

答案 1 :(得分: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