2012-07-12 45 views
0

我試圖改變$ _GET ['p']變量在我的網址爲它自己的,但沒有?=。

例子:
www.example.com/?p=about到www.example.com/about

的問題是,我的htaccess的碼位也反應到子文件夾以及。

如果我要訪問我的文件夾中的圖像作爲一個例子,我得到:
www.example.com/images/?p=images

如何確保我的.htaccess忽略任何子文件夾?

這是我目前使用
RewriteEngine on
RewriteBase /
# Rewrite page include
#RewriteRule ^(\w+)$ index.php?p=$1

對不起,是我不好交代了的.htaccess。

-Banana

回答

1
RewriteEngine on 

# ignore existing files (only apply to non-file) 
RewriteCond %{REQUEST_FILENAME} !-f 

#ignore folders (only apply to non-folder) 
RewriteCond %{REQUEST_FILENAME} !-d 

# here you might also want to exclude some specific locations... 
RewriteCond %{REQUEST_URI} !^(images|css|js)/ 

# finally, apply the rule... 
RewriteRule ^(\w+)$ index.php?p=$1 [L] 

所有RewriteCond條件被鏈接(僅當它們全部通過,然後規則被應用)。

+0

感謝隊友^^,正是我所需要的。 – MisterBla 2012-07-27 21:37:26