내 웹 앱 학습을 위해 자체 MVC 프레임 워크에서 작업하고 있지만 정적 리소스를 처리하는 데 문제가 있습니다. 응용 프로그램, 일명 프론트 컨트롤러에 단일 엔트리 포인트를 갖기 위해 노력하고 있습니다. 프로젝트/모든 .htaccess가 index.php에 요청 URI를 전달하는 app/folder에 모든 요청을 리디렉션하는 .htaccess 파일이 있습니다. (app /에서는) 요청을 적절한 컨트롤러에 위임합니다.아파치가 정적 콘텐츠를 올바르게 제공하지 않음
그러나 javascript 나 계단식 스타일 시트와 같은 정적 인 콘텐츠를 제공하려고 할 때 app/index.php를 통해 여전히 리디렉션됩니다. 또한 /var/log/apache2/errors.log에 "favicon.ico가/var/www에 존재하지 않습니다."라는 오류가 발생합니다 (~/www에 대한 심볼릭 링크 때문일 수도 있습니다). 나는 때문에 내 프로젝트 루트의 루트 디렉토리에 다음의 .htaccess 파일에 기대하지 않는다 '
<IfModule mod_rewrite.c>
RewriteEngine On
# ensure request is not path to filename or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# redirect all requests to index.php?url=PATHNAME
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
왜 수 있습니다 : 여기
<IfModule mod_rewrite.c>
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase/
# ----------------------------------------------------------------------
# Suppress the "www." at the beginning of URLs
# ----------------------------------------------------------------------
# The same content should never be available under two different URLs - especially not with and
# without "www." at the beginning, since this can cause SEO problems (duplicate content).
# That's why you should choose one of the alternatives and redirect the other one.
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [R=301,L]
#----------------------------------------------------------------------
# Route static resources to respective files
#----------------------------------------------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond public/$0 -f
RewriteRule ^.+\.(jpg|gif|png|ico|css|js)$ /public/$0 [L]
#----------------------------------------------------------------------
# Redirect all other requests to the app folder
#----------------------------------------------------------------------
RewriteRule ^$ app/ [L]
RewriteRule (.*) app/$1 [L]
</IfModule>
내 응용 프로그램/폴더에 htaccess로입니다 정적 콘텐츠를 올바르게 제공합니까? 이것은 public /에 대한 모든 정적 요청을 보내려고하지 않고 있다면 css, jpg, png, js 등의 파일이있는 곳에서 나에게 의미가 있습니다. 하지만 거기에 공개 디렉토리에 이러한 파일에 대한 요청을 보내려면 RewriteCond 규칙이 ... 혼란?
다음/ /.htaccess /app/.htaccess /app/index.php /public/static.js (for example)
내가이 문제를 해결하기 바라고, 가지고 올 것입니다 : 루트 폴더에 htaccess로
모든 파일을 필터링하지만 여전히 작동하지 않으므로'RewriteCond % {REQUEST_FILENAME}! -f'을 제거하려고 시도했습니다. – Andrew