그래서 내 codeigniter 앱에서 URL을 삭제하려면 .htaccess를 사용하고 있습니다. (특정 컨트롤러가되는 index.php를 위해 [/ 요청을 재 작성))내부 서버 오류가 발생하는 htaccess 문제
http://localhost/directory/index.php*
to
http://localhost/directory/*
http://my.domain.com/index.php*
to
http://my.domain.com/*
2를 영구적으로 재
1)의 URL에서 index.php를 제거 : 짧은
, 내가 노력하고 있어요 controller_name]http://localhost/directory/controller1*
to
http://localhost/directory/index.php/controller1*
http://my.domain.com/controller2*
to
http://my.domain.com/index.php/controller2*
내 htaccess로 파일은 현재 다음과 같이 진행됩니다
Options +FollowSymlinks
RewriteEngine On
#RewriteBase/
# Redirect index.php
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule ^(.*)index\.php((/)(.*))?$ /$1/$4 [R=301,L]
첫 번째 문제는 :
이 http://localhost/dir/index.php/controller1
작동하지 않습니다. 대신 http://localhost/dir/controller1
로 리디렉션, 그것은 http://localhost//controller1
로 리디렉션
# Rewrite CI certain controllers
RewriteCond %{THE_REQUEST} directory/(home|other_controller) [NC]
RewriteRule ^(.*)(home|other_controller)(.*)$ /$1index.php/$2$3 [NC,L]
두 번째 문제 ($1
반환 빈 문자열?) : http://localhost/dir/home
에 대한
이 작동하지 않습니다 내부 서버 오류가 있습니다 (너무 많은 리디렉션). 하지만 코드에 R=301
코드가 추가되면 성공적으로 http://localhost/dir/index.php/home
으로 리디렉션됩니다. 그러나 이것은 리디렉션하려는 나의 의도가 아니며, 단지 다시 작성해야합니다.
.. 알려 주시기 바랍니다 :)
감사합니다. @Repox하지만이 내용은 다시 작성됩니다. 'http : // localhost/directory/controller'를'http : // localhost/index.php/controller'로 변경하고, http : // localhost/directory/index.php/controller'로 변경하지 마십시오. –
it ... 또는 htaccess – Brian
@ Brian에 RewriteBase를 설정하면 명시 적으로 dir 이름이나 rewritebase를 쓰지 않고 정규식으로 추가 할 수 있습니까? 그래서이 .htaccess 파일은 로컬 및 프로덕션 용으로 이식 될 것입니다. –