2016-10-03 76 views
0

我一直在试图强制删除我的url的一些不必要的部分,例如删除index.php?从这个网址。如何使用htaccess友好的网址

/index.php?task=boost,boosting&action=index 

以下规则适用于没有帮助

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

应该怎么看起来像正确的规则来隐藏不必要的部分如的index.php或任务或行动?

回答

0

下文规定,你可以使用URL yourdomain.com/boost/index你必须还通过价值任务以某种形式&行动,所以你不能隐藏所有的URL字符串,直到它是一个POST请求。

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([\w-]+)/([\w-]+)$ index.php?task=$1&action=$2 [QSA,NC,L] 
0

说明您可以使用以下

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>