Apache .htaccess管理文件夹的不同规则
这件事我已经坚持了好几天了。我想我在某个地方做错了,但我不能让它为我的生活工作 我正在使用codeigniter,我正在尝试将我的正常页面重写为:Apache .htaccess管理文件夹的不同规则,apache,.htaccess,mod-rewrite,url-rewriting,rewrite,Apache,.htaccess,Mod Rewrite,Url Rewriting,Rewrite,这件事我已经坚持了好几天了。我想我在某个地方做错了,但我不能让它为我的生活工作 我正在使用codeigniter,我正在尝试将我的正常页面重写为: website.com/folder/page.html使用重写规则^(.*)$index.php/$1[L] 这是可行的,但我正在努力使它不重写website.com/folder/admin/folder 但是当我使用我的跟随时,我让它工作了,但是它如此应用它 website.com/folder/page 及 我不想要,我只想要.html &
website.com/folder/page.html使用重写规则^(.*)$index.php/$1[L]
这是可行的,但我正在努力使它不重写website.com/folder/admin/folder
但是当我使用我的跟随时,我让它工作了,但是它如此应用它
website.com/folder/page
及
我不想要,我只想要.html
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymlinks
RewriteBase /folder/
# Don't rewrite admin urls
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^admin/
RewriteRule ^(.*)$ index.php/$1 [L,NC]
#Adds .html to urls without it
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^admin/
RewriteCond %{REQUEST_URI} !\.html
RewriteRule ^(.+)$ $1\.html [L]
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
重新启动发动机
选项+FollowSymlinks
重写库/文件夹/
#不要重写管理员URL
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}^管理员/
重写规则^(.*)$index.php/$1[L,NC]
#将.html添加到URL而不添加它
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}^管理员/
重写条件%{REQUEST\u URI}!\。html
重写规则^(+)$$1\.html[L]
#重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php/$1[L]
您要匹配的%{REQUEST\u URI}
变量没有观察基(/folder/
),因此您必须在您的条件下匹配它。因此,不是:
RewriteCond %{REQUEST_URI} !^admin/
您需要(注意前导斜杠):
或者干脆扔掉^
:
RewriteCond %{REQUEST_URI} !/admin/
RewriteCond %{REQUEST_URI} !^/folder/admin/
RewriteCond %{REQUEST_URI} !/admin/