2016-12-08 10 views
1

I持つルートフォルダ、その中にの/ var/www /のminus_projectと2つだけのファイル:のindex.phpと.htaccessは、すべての要求がindex.phpにリダイレクト

はどのようにapache2のはlocalhost.com/minus_project/ いくつか/ URL /ここで/ ...はindex.phpにのようにすべての要求をリダイレクトするには? マイapache2の設定

<VirtualHost *:80> 
     ServerAdmin [email protected] 
     DocumentRoot /var/www/html 
     Alias /phpinfo /var/www/phpinfo 
     Alias /minus_project /var/www/minus_project 

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

答えて

2
ここ

あなたが別名ディレクトリ内index.phpへのエイリアスとルートのすべてを作成する方法です。

Alias /minus_project /var/www/minus_project 

<Directory /var/www/minus_project> 
    Options Indexes FollowSymLinks MultiViews ExecCGI 
    AllowOverride All 
    Order allow,deny 
    Allow from all 
    Require all granted 

    RewriteEngine On 
    RewriteBase /minus_project/ 

    RewriteRule ^/index\.php$ - [L,NC] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . index.php [L] 
</Directory> 

上記のスニペットをVirtualHostセクションに置き、Apacheサーバーを再起動することを忘れないでください。

+1

コンテナは '.htaccess'ファイルではなく、メインの' .conf'ファイルでのみ有効です(または実際に必要です)。問題は、それについて曖昧です。 –

+0

本当に、 '.htaccess'でも' alias'を使うことはできません – anubhava

+0

私は** sudo a2enmod rewrite **コマンドを実行してからapacheを再起動する以外は大丈夫です。 –

関連する問題