0

我正在尝试将我的 url 中的 $_GET['p'] 变量更改为它自己的变量,但没有?=。

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

问题是我的 htaccess 代码也会对子文件夹做出反应。

如果我想访问我的图像文件夹作为示例,我会得到:
www.example.com/images/ ?p=images

如何确保我的 .htaccess 忽略任何子文件夹?

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

抱歉我的解释不好。

-香蕉

4

1 回答 1

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条件都是链式的(只有当所有条件都通过时,才会应用规则)。

于 2012-07-12T15:42:26.660 回答