0

我希望该网站是 url 友好匹配,因此目录/adm(在我的情况下是管理面板)没有 url 友好

我的 .htaccess

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

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

我只是想这样做我正在学习这条规则意味着在外行命令中。htaccess

4

1 回答 1

1

您的所有脚本都将根据以下重定向到 index.php

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

另外你可以指定文件夹名,文件名不应该遵循上面的规则。这可以通过在您的 htaccess 文件中添加另一个重写条件语句来完成。

RewriteCond %{REQUEST_FILENAME} !(img|anyother folders that you want to ignore|anyother folders that you want to ignore|...)

'|' 用于分隔您要忽略的每个文件夹名称

所以你的 .htaccess 文件将有以下内容

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !(adm|anyother folders that you want to ignore|anyother folders that you want to ignore|...)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]
</IfModule>
于 2013-06-12T07:44:39.853 回答