나는 mod_rewrite
의 작동 방식을 이해할 수 없다고 생각하는 지점에 왔습니다. 이론적으로 나는 그것을 얻었다 고 생각하지만, 단지이 일을 할 수없는 것처럼 보입니다. 나는 다음과 같은 파일 구조가 : 슬프게도또 다른 아파치의 mod_rewrite 패배 한 남자
code
-application/
-bundles/
-laravel/
-public/
-css/
-js/
-img/
-index.php
-storage/
-.htaccess
을 내 httpd.conf
가상 호스트 구성이 있습니다
<Directory path/to/code>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot path/to/code
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
그리고 코드/대중를 가리 키도록 수정할 수 없습니다/그래서 내가 고칠 수 있다고 생각 그것과 함께 .htaccess
. 이제 모든 것을 시도했습니다. 기본적으로 제가하고 싶은 것은 변환해야하는 css, js, img
제외하고, /public/index.php/($1)
에 모든 요청을 변환 할 수 있습니다 : 그래서
/public/css/($1)
/public/img/($1)
/public/js/($1)
내가 example.com/
있는 경우이 그들의 CSS, IMG를 example.com/public/index.php
으로 변경됩니다, JS 등 example.com/public/css
로 변경 것 , img, js.
난 그냥 그것을 :(
내 .htaccess
취한 여러 형태를 할 수 없어, 최근에 나는 모든 것을 포기하고 그냥 다음과 같을 수 :
<IfModule rewrite_module>
RewriteEngine on
RewriteRule ^(.*)$ /public/index.php/$1
</IfModule>
이, 줘 500 내부 서버 오류 (다시 말해서 나에게 명확하지는 않지만 그래도 명확한 루프가 아닙니다)
그래서 내 생각은입니다.(의사 코드) :
<IfModule rewrite_module>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/css
RewriteRule ^css/(.*)$ /public/css/$1
RewriteCond %{REQUEST_URI} ^/img
RewriteRule ^img/(.*)$ /public/img/$1
RewriteCond %{REQUEST_URI} ^/js
RewriteRule ^js/(.*)$ /public/js/$1
RewriteRule ^(.*)$ /public/index.php/$1
</IfModule>
어떤 생각을 어떻게 할 수 있습니까? 나는 내가 뭘 잘못하고 있는지 조금 이해하고 싶다. 나는 좋은 글을 쓰는 방법을 알아 내려고한다. mod_rewrite
.htaccess
파일.
저는 Windows 7, Apache2.2입니다.
미리 감사드립니다.
RewriteRules 끝 부분에 [L] 옵션이 있어야 mod_rewrite가 처리 규칙을 종료하고 처리하는 것을 알 수 있다고 생각합니다. – HeatfanJohn
그건 작동하지 않습니다. 'L' 플래그는 현재 실행을 멈추지 만 다시 작성된 모든 경로는 시작부터 .htaccess 파일을 통해 다시 돌아 가야합니다. – Bobulous