2015-07-06 4 views
3

Я пытаюсь перенаправить пользователя, если установлена ​​папка, но пока мне не повезло.Htaccess, перенаправление, если существует папка

Ниже приведен файл htaccess.

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.

Project Structure is 

htdocs/enc/project/ 
|-- application/ 
| |-- project 
| 
|-- system/ 
| |-- project 
| 
|-- install/ 
| |-- test/ 
| | |-- test_main.php 
| | 
| |-- index.php 
| 
|-- htaccess 
+0

'LOCALHOST/прил/project' – LefterisL

+0

я редактировал вопрос с моей структурой проекта – LefterisL

+0

я попробую сейчас и дам вам знать. Спасибо – LefterisL

ответ

0

Попробуйте эти правила

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] 
+1

Вы, сэр, вы мужчина – LefterisL

1

Это один из способов написания его, что работает:

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_URI} !(install) [NC] 
# ...redirect to setup - with a 302 (temporary redirect) to make sure the browser won't cache the redirect. 
RewriteRule ^(.*) /enc/project/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] 
+0

Да, проблема в этом, хотя я получаю пустую страницу и перенаправляет каждый ' css' или файл, который я пытаюсь загрузить в папку установки – LefterisL

Смежные вопросы