2017-03-16 7 views
1

私は少し問題があります。 私はgithubで簡単なPHPフレームワークを使用し、それに取り組み、新しい機能を追加しました。Apache mod_rewriteとph

私は助けを持っていたフレームワークはこれです: https://github.com/panique/mini

すべてはMAMP環境で完璧に動作しますが、今私が住んでいるウェブサイトやapacheの環境でテストするつもりだったときのことが動作しません。良い。 私は、ディレクトリをApacheのために使用すべきディレクトリに向けるので、明らかにインデックスファイルを読むことができます。

しかし、私はそれが私に与えてはApacheになり、コントローラ(domain.com/login)への呼び出しにするつもりです:

は、「見つかりません:要求されたURL /ログインはこのサーバー上に見つかりませんでした。 "

私が書き換えを有効にしている。)(サービスa2enmod書き換え、と私は二重にチェックしてのphpinfoで見たときにそれがロードされたモジュールです。

# Necessary to prevent problems when using a controller named "index" and having a root index.php 
Options -MultiViews 

# Activates URL rewriting 
RewriteEngine On 

# Prevent people from looking directly into folders 
Options -Indexes 

# If the following conditions are true, then rewrite the URL: 
# If the requested filename is not a directory, 

RewriteCond %{REQUEST_FILENAME} !-d 
# and if the requested filename is not a regular file that exists, 
RewriteCond %{REQUEST_FILENAME} !-f 
# and if the requested filename is not a symbolic link, 
RewriteCond %{REQUEST_FILENAME} !-l 
# then rewrite the URL in the following way: 
# Take the whole request filename and provide it as the value of a 
# "url" query parameter to index.php. Append any query string from 
# the original URL as further query parameters (QSA), and stop 
# processing this .htaccess file (L). 
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L] 

「/ var/www/htmlと設定/ PHPプロジェクト/パブリック」に私は私のバーチャルホストファイル」 で指されているディレクトリを(位置して.htaccessファイルには、以下のとおりです。

<Directory /> 
     Options FollowSymLinks 
     AllowOverride None 
     Require all denied 
</Directory> 

<Directory /usr/share> 
     AllowOverride None 
     Require all granted 
</Directory> 

<Directory /var/www/html/> 
     Options Indexes FollowSymLinks 
     AllowOverride None 
     Require all granted 
</Directory> 

#<Directory /srv/> 
#  Options Indexes FollowSymLinks 
#  AllowOverride None 
#  Require all granted 
#</Directory> 

AccessFileName .htaccess 

apache.conf

00-は、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.domain.com 
     ServerAlias domain.com 
     ServerAdmin [email protected] 
     DocumentRoot /var/www/html/php-project/public 
     <Directory /> 
       AllowOverride All 
     </Directory> 
     #DocumentRoot /var/www/html 
     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
     #Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

私は、pを思ういけません問題はPHP自体の中にあります。 なぜ、私は非常に多くのクラスから私のコードを追加していませんが、コードは私が質問の冒頭のフレームワークに基づいて言ったようにです。

confの中に明らかな問題がありますか? 回答を検索して検索しましたが、正しく取得していないようです。だから私は本当に本当にいくつかの助けに感謝します。 質問がありましたら、尋ねてください。 おかげ

+2

'.htaccess'がでも光栄ているかどうかを判断するために、この最も簡単な方法は、目的に構文エラーを作ることです。あなたが500 Server Errorを取得した場合、Apacheの観点からすべてが機能します。 –

答えて

0

のapache2でのアクセス書き換えモジュールの適切な方法に従ってください。

まずコマンド - の下に使用してApacheに書き換えモジュールを有効にします。

$ sudo a2enmod rewrite 

オープンapache2.confファイル

$ nano /etc/apache2/apache2.conf 

更新セクション

<Directory /var/www/html/> 
     Options Indexes FollowSymLinks 
     AllowOverride All 
     Require all granted 
</Directory> 

からセクションを削除します00-default.conf 以下の行を削除してください

  <Directory /> 
       AllowOverride All 
     </Directory> 

は、その後最終的にあなたのApache2を再起動します。

$ sudo service apache2 restart 

または

$ sudo /etc/init.d/apache2 restart