나는 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]
나는 잠시 동안 놀았으므로 처음 두 명령이 작동한다는 것을 알고 있습니다.
(PHP/Apache) 호환성 문제 일 수 있습니까?
도움 주셔서 감사합니다.
서버에서이 명령을 실행하여 오류를 방지 할 수있었습니다 : "sudo a2enmod rewrite". 그러나 코드는 ist가해야하는 것은 아닙니다. –
스택 오버플로는 프로그래밍 및 개발 관련 질문을위한 사이트입니다. 이 질문은 프로그래밍이나 개발이 아니기 때문에 주제와는 거리가 먼 것처럼 보입니다. 도움말 센터에서 [여기에서 내가 질문 할 수있는 항목은 무엇입니까?] (http://stackoverflow.com/help/on-topic)를 참조하십시오. 아마도 [웹 애플리케이션 스택 교환] (http://webapps.stackexchange.com/), [웹 마스터 스택 교환] (http://webmasters.stackexchange.com/) 또는 [유닉스 및 리눅스 스택 교환] (http : // unix.stackexchange.com/)이 더 나은 곳입니다. – jww