17

私はこの質問がすでに尋ねられていることを知っています.私はそれらをすべて試しましたが、まだURLからindex.phpを削除できません. ここに私の詳細があります

Ubuntu 12.10
PHP : 5.4.6
Mod_rewrite in on
CI verson: 2.1

.htacess は次のようになります。

RewriteEngine On
RewriteBase /projectname

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

以下のリンクも見ますが、うまくいき ません.URL CIベースのサイトからindex.phpを削除できません

codeigniter のパスにある「index.php」を削除する方法

私の「/etc/apache2/sites-available/default」は次のようになります。

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None 
        </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

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

どんな助けでも大歓迎です!!

4

3 に答える 3

69

ステップ1 :

これをhtaccessファイルに追加します

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

ステップ2 :

codeigniter 設定で index.php を削除します

$config['base_url'] = ''; 
$config['index_page'] = '';

ステップ 3 :

Apache 構成で htaccess のオーバーライドを許可する (コマンド)

sudo nano /etc/apache2/apache2.conf

ファイルを編集して変更します

AllowOverride All

wwwフォルダ用

ステップ 4 :

apache mod rewrite を有効化 (コマンド)

sudo a2enmod rewrite

ステップ 5 :

Apache を再起動する (コマンド)

sudo /etc/init.d/apache2 restart
于 2013-05-15T06:22:29.407 に答える