2017-12-23 2 views
-1

나는 Raspbian Stretch Lite가 설치된 RaspberryPi B +에서 웹 사이트를 실행 중입니다. 나는 PHP 7.0.19와 아파치 2.4.25를 설치했다. 내가 호스팅하고있는 웹 사이트의 URL에서 파일 확장명을 없애기 위해 ".htaccess"파일을 "var/www/html"폴더에 만들었는데, 여기에는 내 웹 사이트 파일도 있습니다. . 나는 추가 :에Apache .htaccess 오류

<Directory "/var/www"> 
     AllowOverride All 
</Directory> 

내 "등/아파치/사이트 이용 가능한 000-default.conf /"파일. 그래서 전체 파일은 다음과 같습니다

<VirtualHost *:80> 
     # The ServerName directive sets the request scheme, hostname and port that 
     # the server uses to identify itself. This is used when creating 
     # redirection URLs. In the context of virtual hosts, the ServerName 
     # specifies what hostname must appear in the request's Host: header to 
     # match this virtual host. For the default virtual host (this file) this 
     # value is not decisive as it is used as a last resort host regardless. 
     # However, you must set it for any further virtual host explicitly. 
     #ServerName www.example.com 

     ServerAdmin [email protected] 
     DocumentRoot /var/www/html 

     # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
     # error, crit, alert, emerg. 
     # It is also possible to configure the loglevel for particular 
     # modules, e.g. 
     #LogLevel info ssl:warn 

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 

     # For most configuration files from conf-available/, which are 
     # enabled or disabled at a global level, it is possible to 
     # include a line for only one particular virtual host. For example the 
     # following line enables the CGI configuration for this host only 
     # after it has been globally disabled with "a2disconf". 
     #Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

<Directory "/var/www"> 
     AllowOverride All 
</Directory> 

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet 
다음

내 htaccess로 파일에이 코드를 추가 : 내 웹 사이트의 모든 페이지에 갈 때

# Hide these filetypes in the browser file explorer 
IndexIgnore *.txt *.html *.php *.css *.js *.png *.jpg *.jpeg *.ico 

# Custom 404 Page 
ErrorDocument 404 /code/multiPage/404.php 

# Add a .www to the URL 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule ^(.*)$ http://www.canbike.ca/hash/$1 [R=301,L] 

# If not a directory, remove the trailing slash 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]+)/$ $1 [R=301,L] 

# Redirect external .php requests to an extensionless url 
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/ 
RewriteRule ^(.+)\.php$ $1 [R=301,L] 

# Resolve extensionless php url, to the php file 
RewriteRule ^([^/.]+)$ $1.php [L] 

이 날이 오류를 제공합니다 500 Internal Server Error (내부 서버 오류 500)

나는 잠시 동안 놀았으므로 처음 두 명령이 작동한다는 것을 알고 있습니다.

(PHP/Apache) 호환성 문제 일 수 있습니까?

도움 주셔서 감사합니다.

+0

서버에서이 명령을 실행하여 오류를 방지 할 수있었습니다 : "sudo a2enmod rewrite". 그러나 코드는 ist가해야하는 것은 아닙니다. –

+0

스택 오버플로는 프로그래밍 및 개발 관련 질문을위한 사이트입니다. 이 질문은 프로그래밍이나 개발이 아니기 때문에 주제와는 거리가 먼 것처럼 보입니다. 도움말 센터에서 [여기에서 내가 질문 할 수있는 항목은 무엇입니까?] (http://stackoverflow.com/help/on-topic)를 참조하십시오. 아마도 [웹 애플리케이션 스택 교환] (http://webapps.stackexchange.com/), [웹 마스터 스택 교환] (http://webmasters.stackexchange.com/) 또는 [유닉스 및 리눅스 스택 교환] (http : // unix.stackexchange.com/)이 더 나은 곳입니다. – jww

답변

0

발견 mod_rewrite.so /를이 내가 사용하고있는 아파치 버전은 이전 버전과 다른 파일 구조를 가지고 있습니다. 이 버전에는 httpd.conf 파일이 없습니다. 내가 올바른 설정을했지만 내 .htaccess 파일에 RewriteEngine on가 없기 때문에 내가했던 일 중 일부는 새 버전에서 다르게 수행되어야합니다. 나는 달리고있다.

0

귀하의 htaccess 파일의 Sytax가 좋게 보입니다. 아파치의 httpd.conf 파일을 확인하고이 모듈을로드하고 있는지 확인 :

  • 을 LoadModule rewrite_module 모듈은 내가
  • 을 LoadModule autoindex_module 모듈/mod_autoindex.so
+0

httpd.conf 파일을 찾을 수 없습니다. –

+0

또한 "찾기"를 사용하여 찾을 수 없습니다 : "찾기 : 'httpd.conf': 해당 파일이나 디렉토리가 없습니다." –

+0

http.conf : https://stackoverflow.com/을 찾는 데 도움이 필요하십니까? 질문/12202021/lost-httpd-conf-file-located-apache – Nejc