우분투 14.04를 사용하고 있으며 LAMP 환경이 있습니다. dir / var / www / html / project1에 프로젝트 중 하나가 있습니다. URL 규칙을 다시 작성하기 위해 .htaccess 파일에 액세스 할 수 없습니다 .
이를 위해 /etc/apache2/apache2.conf 파일 에서 변경해야 합니다.
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All # change None to All
Order allow,deny
allow from all
Require all granted
</Directory>
그러나이 변경 후 Apache 서버는 "내부 서버 오류"오류를 표시하고 아파치는 모든 웹 사이트 (프로젝트)에 오류를 제공합니다.
그리고 'AllowOverride None' 을 변경하면 사이트가 올바르게 실행되고 있지만 .htaccess 파일이 작동하지 않습니다.
'내부 서버 오류' 과 같은 또 다른 프로젝트에 htaccess로 파일 때문이다
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
htaccess 파일에서 아무것도 이해할 수 없습니다. PLZ는 htaccess 파일과 동일한 의미를 다시 작성하도록 도와줍니다.
감사
기본 블록에서 지시문을 변경하는 대신 프로젝트 디렉토리에 대해 특별히 별도의 블록을 사용해야합니다.
<Directory /var/www/html/project1>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
이렇게하면이 특정 디렉토리에서 .htaccess 파일 만 사용할 수 있습니다.
발생하는 500 오류는 .htaccess 파일의 잘못된 구문 때문일 수 있습니다. 모든 .htaccess 파일에있는 것을 보여 주면 도움이 될 것입니다.
또는 /var/log/apache2/error.log의 Apache 오류 로그에서 오류에 대한 자세한 정보를 볼 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다