작동하지 않는 htaccess 파일이있는 프로젝트에서 내 수업을 진행하고 있습니다. 나는이있다 :htaccess의 규칙 충돌
내가 /section/function/
같은 URL을 조회 할 경우에, 나는 /myroot/index.php?type=section &을 얻어야한다 : 사실
SetEnvIf Request_URI^root=/myroot/
RewriteRule ^(assets|inc) - [L]
RewriteRule ^section[/]?$ %{ENV:root}section/index
RewriteRule ^section/function/(.*)$ %{ENV:root}index.php?type=section&action=function [L]
RewriteCond %{QUERY_STRING} ^(.*)?$
RewriteRule ^section/(.*)$ %{ENV:root}index.php?type=section&action=view [L]
RewriteRule ^index\.php$ - [L]
를, 내가 이해하지 못하는 세 가지가있다 조치 = 기능을했지만 내 브라우저에서 localhost/section/function
이 발생하여 오류가 발생합니다. url은 양방향으로 변환됩니까? myroot/index.php? type = section & action = 브라우저에 /section/function/
으로 나타나는 함수입니다. 마지막 줄을 지우면 빈 오류 페이지가 나타납니다. 왜 그렇습니까?
편집 : 그래서 컨 포멀 올라프 DIETSCHE는 말에
, 내가
한다 SetEnvIf REQUEST_URI^루트 =/myroot/
RewriteRule ^(assets|inc) - [L]
RewriteRule ^section[/]?$ %{ENV:root}section/index
RewriteRule ^section/function/(.*)$ %{ENV:root}?type=section&action=function [L]
RewriteCond %{QUERY_STRING} ^(.*)?$
RewriteRule ^section/(.*)$ %{ENV:root}?type=section&action=view [L]
RewriteRule ^index\.php$ - [L]
에 규칙을 변경하지만 <a href="section/somefunction"></a>
에 클릭하면, I 페이지 localhost/section/some function
을 보여줍니다. 난 정말 당신이 규칙이 작동하려면에 대한 htaccess로에
RewriteEngine on
이 있어야
설명해 주셔서 감사합니다. 물론 RewriteEngine을 켜기로 설정 했는데도 여전히 작동하지 않습니다. 왜 그렇습니까? – user1611830
@ user1611830 필자는 테스트 환경에서 규칙을 시험해 보았고, *'/ section/function'을'/ myroot/index.php'로 다시 작성했습니다. error.log 메시지가 없으면 알기가 어렵습니다. 예를 들어'/ myroot /'가 서브 디렉토리가 아닌 * 문서 루트 * 인 경우,'index.php'에 그 파일을 첨가해서는 안됩니다. 그것이 하위 디렉토리라면'index.php'가 없을 수도 있습니다. PHP 스크립트 자체에 오류가있을 수 있습니다. –
죄송합니다. 귀찮게하지 않으려 고합니다. 하지만 실제로/myroot는 루트 폴더이므로 규칙을 업데이트 (규칙 참조)하지만 아무 것도 변경하지 않았습니다. – user1611830