2017-02-17 5 views
1

mod_rewriteを使用しますが、動作していないようです。私は起動しました.htaccessで設定しましたが、何も動作していないようです。私は私のURLにindex.phpで表示しないようにしたい :Apache mod_rewriteが動作しません

: の代わり

localhost/index.php/admin/login 

私はここでのUbuntu 下だ

localhost/admin/login 

を表示するには、言う私のphpinfo()であります

enter image description here

これは私の.htaccessです:

# Make sure directory listing is disabled 
Options +FollowSymLinks -Indexes 
RewriteEngine on 

#RewriteBase /virtualpost 
RewriteCond %{HTTP_HOST} ^localhost$ 
RewriteRule . - [E=REWRITEBASE:/virtualpost] 

#RewriteBase/
RewriteCond %{HTTP_HOST} ^((?!localhost).)*$ 
RewriteRule . - [E=REWRITEBASE:/] 

# Remove index.php from URL 
RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ 
RewriteCond %{THE_REQUEST}    ^[^/]*/index\.php [NC] 
RewriteRule ^index\.php(.*)$   $1 [R=301,NS,L] 

# Keep people out of codeigniter directory and Git/Mercurial data 
RedirectMatch 403 ^/(system\/virtualpost\/cache|system\/codeigniter|\.git|\.hg).*$ 

# Send request via index.php (again, not if its a real file or folder) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
<IfModule !mod_php5.c> 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

これは私の/etc/apache2/sites-available/000-default.confです:

<VirtualHost *:80> 
    SetEnv MYSQL_DB_HOST localhost 
    SetEnv MYSQL_USER root 
    SetEnv MYSQL_PASSWORD spaces 
    SetEnv MYSQL_DB_NAME clevvermail 
    <Directory ...> 
     AllowOverride All 
    </Directory> 
    DocumentRoot /var/www 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    LoadModule rewrite_module modules/mod_rewrite.so 
</VirtualHost> 
+0

が見つかりません 要求されたURL/admin/loginがこのサーバーに見つかりませんでした。 – bourax

+0

あなたの '.htaccess'が本当に有効かどうかを確認するには、あなたの' .htaccess'の上に何らかのガベージ(ランダム)のテキストを置き、ブラウザーであなたのページにアクセスしたときに500(内部サーバー) 。 500エラーは.htaccessが有効であることを意味します。 – anubhava

+0

hmmm、いいえ、私は500のエラーを取得しませんでした。だから私は.htaccessをどのように活性化すべきですか? – bourax

答えて

2

私はapache2のを設定への持っていたことを考え出しました。 confファイル/etc/apache2/apache2.conf and change

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride None <<-- Rewriting desactivated 
    Require all granted 
</Directory> 

から

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride All <<--Activate rewriting 
    Require all granted 
</Directory> 
関連する問題