2012-03-18 24 views
0

今日、私は、.htaccessがブラウザのURLからファイル拡張子を自動的に削除するこの機能を実現したかったのです。 は、私はいくつかの.htaccessのコードを使用してみました例のユーザーが
mylink.php
にユーザを取るためのリンクをクリックしたためにそれが彼を取るが、
ファイル拡張子apacheサーバーを削除する



.PHPを削除する必要が言うことができますが、彼らあまりしなかった。

も、私はそう

  • はlocalhost /登録< <この1つが正常に動作しますが、それはのように振る舞うので、私は拡張子を削除したい自動
  • はlocalhost// < <を登録この1つは、すべてのスタイリングを失いようなページにアクセスすることができます新しいフォルダ内のページ
  • の.htaccessコードが

    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.html -f 
    RewriteRule ^([^/]+)/$ $1.html 
    
    # Forces a trailing slash to be added 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ 
    RewriteRule (.*)$ /$1/ [R=301,L] 
    

    任意のアイデアの人ですか?

    +0

    * * .htaccessは何を試しましたか?あなたが持っている実際のコードを表示してください。 – Amber

    +0

    それを修正しました... –

    +0

    [do-it-yourself universal header/footer.php]の可能な複製(http://stackoverflow.com/questions/9215791/do-it-yourself-universal-header-footer- php) – hakre

    答えて

    0
    RewriteEngine On 
    
    # Change this to the appropriate base (probably just/in your case) 
    RewriteBase /stackoverflow/9762238/ 
    
    # Any url that requests a .php file on the base will be redirected to dir with same base name 
    # The condition is important to prevent redirect loops! 
    RewriteCond %{ENV:REDIRECT_STATUS} !=200 
    RewriteRule ^(.*)\.php$ $1/ [R=301,L] 
    
    # Requests for directories that do not actually exist will be be translated into php file requests 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule (.+)/$ $1 [L] 
    
    関連する問題