2017-01-04 4 views
0

私はCodeIgniterのインストールと別のsimple.phpファイルをフレームワークディレクトリの外に持っています。 simpleページから.php拡張子を削除します。フレームワークとsimple.phpページを使用する単純なページから.phpを削除したい

現在、私はCodeIgniterの要求からindex.phpを削除し、このコードを使用していますが、それは、フレームワークの外で作業していない:

RewriteOptions inherit 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php/$1 [PT,L] 

どのように私は.php拡張機能を削除することができますか?

答えて

0

たとえば、/foo/bar/my-ci-appにCodeIgniterインストールがあり、その中に.htaccessというファイルがあるとします。

また、/foo/bar/simple.php(フレームワークの外側)にあるsimple.phpもあります。そして、そのsimple.phpファイルから.php拡張子を削除したいのですが、

htaccess fileで定義されたディレクティブは、そのディレクトリとそのサブディレクトリにのみ有効です。 simple.phpファイルはCodeIgniterのインストール外にあるため、htaccessファイルはそのディレクティブが後方に反映されないため、あなたのためのものではありません。

simple.phpファイルの横にある別のhtaccessファイルがfoo/bar/.htaccessに存在する必要があります。 PHP拡張モジュールを削除する必要がある書き換えルールは次のとおりです:

Options +FollowSymLinks 

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteBase/

    # Just to be sure that these rules has no conflict with your 
    # codeigniter rewrite rules, we're gonna discard the following 
    # rewrite rule if the request uri contains its directory name. 
    RewriteCond %{REQUEST_URI} !my-ci-app 

    # If the corresponding php file exists 
    RewriteCond %{REQUEST_FILENAME}.php -f 

    # And the request uri does not contain a php file format, 
    # for example, whatever.php, rewrite the request to a file 
    # named as %{REQUEST_FILENAME} (simple in your case) and add 
    # a .php extension to it. 
    RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L] 
</IfModule> 
## Results 
# simple => simple.php 
# example => example.php 
関連する問題