로컬 사이트에 대해 다음 디렉토리 구조가 있습니다.Apache RewriteCond 및 RewriteRule을 사용하여 기존 파일 및 디렉토리를 건너 뜁니다.
mysite
|_ css
|_ images
|_ logo.png
|_ js
|_ app
|_ index.php
|_ .htaccess
나는 존재하지 않는 디렉토리에 http://mysite.dev/app/index.php
로 리디렉션 재 작성 아파치 URL을 시도하고있다. 예를 들어 는 http://mysite.dev/en/home
는 내 .htaccess
파일이 재 작성 규칙을 시도 http://mysite.dev/app/index.php
으로 다시 작성됩니다
Options -Indexes
DirectoryIndex index.php index.html index.htm
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^app/index.php [L]
</IfModule>
그러나 그것은 기존의 모든 디렉토리와 노 기존 디렉토리에 다시 작성됩니다. 내가 http://mysite.dev/mysite/images/logo.png
를 검색 할 때, , 내가 두 RewriteCond
라인 위의 라인을 추가 http://mysite.dev/mysite/app/index.php
에 다시 작성되어 있지만 작동하지 않았다.
내 목표는 파일이나 디렉토리가있는 경우 규칙을 건너 뛰는 것입니다. 이 목적으로 RewriteCond
과 RewriteRule
을 어떻게 쓸 수 있습니까?
[편집]
문제점을 발견했습니다. 내 사이트에 추가 한 가상 호스트 때문입니다. 내가 httpd-vhost.conf
에 다음 코드 줄이 있습니다
<VirtualHost mysite.dev>
DocumentRoot "C:/xampp/htdocs/mysite"
ServerName mysite.dev
ServerAlias mysite.dev
<Directory "C:/xampp/htdocs/mysite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
내가 http://mysite.dev/images/logo.png
를 탐색 할 때, RewriteCond
제대로
작동하지 않습니다하지만 가상 호스트를 제거하고 난 http://localhost/mysite/images/logo.png
를 탐색 할 때, 그것을 잘 작동하고 난을 참조하십시오 이미지가 올바르게 표시됩니다.
가상 호스트의 문제점과 충돌이 무엇인지 모르겠으며 RewriteCond
입니다. 가상 호스트 지시어에서
입니까? –
Apache에서'images/logo.png'를 볼 수 있습니까? 그렇지 않은 경우, Apache는 존재하지 않는 것으로 간주합니다. RewriteRule을 제거하면 호스트가'mydomain.com/images/login.png'을 제공 할 수 있습니까? –
다시 쓰기 로깅 켜기 http://stackoverflow.com/questions/9632852/how-to-debug-apache-mod-rewrite –