2016-07-24 19 views
0

私のURLからこのコードで.phpのエンディングを削除しようとしましたが、機能しません。これは私の.htaccessファイルです。URLからの.php拡張子の削除(.htaccess)

# Apache Rewrite Rules 
<IfModule mod_rewrite.c> 
Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/

    # Add trailing slash to url 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$ 
RewriteRule ^(.*)$ $1/ [R=301,L] 

    # Remove .php-extension from url 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^([^\.]+)/$ $1.php 

    # End of Apache Rewrite Rules 
</IfModule> 

私はそのファイルを自分のpublic_htmlフォルダに入れます。何らかの理由でexample.com/indexの代わりにexample.com/index.phpが表示されています。任意の手掛かりはなぜですか?

答えて

0

この

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 
をお試しください
関連する問題