2017-12-23 11 views
-1

私はRaspbian Stretch LiteをインストールしたRaspberryPi B +でウェブサイトを作成しています。私はPHP 7.0.19とApache 2.4.25をインストールしています。私はホストしているウェブサイトのURLのファイル拡張子を取り除こうと思っていたので、 ".htaccess"ファイルを "var/www/html"フォルダに作成しました。 。私が追加:Apache .htaccessエラー

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

を私の "など/ apache2の/サイト利用可能/ 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内部サーバーエラー)

私はこれをしばらく前に遊んでいたので、最初の2つのコマンドが機能することがわかりました。

これは(PHP/Apache)の互換性の問題ですか?

ありがとうございました。

+0

サーバーでこのコマンドを実行するとエラーを防ぐことができました: "sudo a2enmod rewrite"しかし、コードはistがやろうとしていることではありません。 –

+0

Stack Overflowは、プログラミングおよび開発に関する質問のサイトです。この質問は、プログラミングや開発に関するものではないので、話題にはならないようです。ヘルプセンターの[ここではどのトピックを参照できますか](http://stackoverflow.com/help/on-topic)を参照してください。おそらく[Webアプリケーションスタック交換](http://webapps.stackexchange.com/)、[Webmaster Stack Exchange](http://webmasters.stackexchange.com/)、[Unix&Linux Stack Exchange](http:// unix.stackexchange.com/)がより良い場所になるでしょう。 – jww

答えて

0

私が使用しているApacheのバージョンは以前のバージョンとは異なるファイル構造を持っています。このバージョンにはhttpd.confファイルはありません。私は正しい設定をしていましたが、私の.htaccessファイルにRewriteEngine onがありませんでした。私がやっていることのいくつかは、新しいバージョンでは別のやり方で行わなければなりません。私はそれを実行している。

0

あなたのhtaccessファイルのSytaxはよく見えます。あなたのApacheのhttpd.confファイルをチェックして、あなたはこれらのモジュールをロードしていることを確認してください。私はことがわかっ

  • のLoadModuleのrewrite_moduleモジュール/ mod_rewrite.so
  • のLoadModule autoindex_moduleモジュール/ mod_autoindex.so
+0

httpd.confファイルが見つかりませんでした。 –

+0

"find"を使っても見つかりませんでした: "find: 'httpd.conf':そのようなファイルやディレクトリはありません" –

+0

http.confの検索にはこちらをご覧ください:https://stackoverflow.com/質問/ 12202021/lost-httpd-conf-file-located-apache – Nejc