htaccess,如果文件夹存在则重定向

编程入门 行业动态 更新时间:2024-10-19 19:31:28
本文介绍了htaccess,如果文件夹存在则重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果文件夹安装存在,但我到目前为止还没有运气,我正在尝试重定向用户.

I'm trying to redirect the user if the folder install exists but i had no luck so far.

下面是我的htaccess文件.

Below is my htaccess file.

RewriteEngine On RewriteBase /enc/project/ # If the setup directory exists in the document root... RewriteCond %{DOCUMENT_ROOT}/install -d # ...and you're not in isntall.. RewriteCond %{REQUEST_URI} !(install) [NC] # ...redirect to setup - with a 302 (temporary redirect) to make sure the browser won't cache the redirect. RewriteRule ^(.*) /install [L,redirect=302] # ...rest of htaccess for codeigniter RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

codeigniter项目位于服务器的/enc/project/中,这就是RewriteBase的原因.

The codeigniter project is in the /enc/project/ in my server thats why the RewriteBase.

Project Structure is htdocs/enc/project/ |-- application/ | |-- project | |-- system/ | |-- project | |-- install/ | |-- test/ | | |-- test_main.php | | | |-- index.php | |-- htaccess

推荐答案

尝试这些规则

RewriteEngine On RewriteBase /enc/project/ # If the setup directory exists in the document root... RewriteCond %{DOCUMENT_ROOT}/enc/project/install -d # ...and you're not in isntall.. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # ...redirect to setup - with a 302 (temporary redirect) to make sure the browser won't cache the redirect. RewriteRule !^install/ install/ [L,NC,R=302] # ...rest of htaccess for codeigniter RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

更多推荐

htaccess,如果文件夹存在则重定向

本文发布于:2023-10-31 13:10:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546185.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   重定向   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!