2012-07-12 47 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