2015-04-04 32 views
1

我想使用「假」子目錄作爲GET請求。對不起,我的措辭不準確。Sub directory as GET with htaccess

我現在有這個在我的htaccess:

RewriteEngine on 
RewriteRule ^pggr/(.*)$ index.php?p=$1 

所以http://example.com/pggr/blah作爲http://example.com/?p=blah處理。

但是我想從URL中移除pggr一部分,所以它也不過http://example.com/blah

回答

1

您可以使用此規則:

RewriteEngine on 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule (.+) index.php?p=$1 [L,QSA] 
+1

優秀的先生!完美的作品。 – 2015-04-04 06:50:32

+0

不客氣,很高興它的工作。 – anubhava 2015-04-04 07:02:20

+1

我是的,我知道,我只需要等待大約五分鐘就可以接受它,然後離開。 – 2015-04-04 14:05:42