ページが存在しない場合は、.php拡張子を追加します(ただしURLバーで非表示にします)。ダブル.htaccessのルール
3.ページが存在せず、.php拡張子が存在しない場合、単一のページ(query.php)を開き、URLバーに入力した内容を追加します可変パラメータとして(URLバーで打つ)。
例ファイル構造:
のindex.php
pricing.php
query.php
例試験:
[domain]/pricing.php -> [domain]/pricing (showing the pricing.php page)
[domain]/pricing -> [domain]/pricing (showing the pricing.php page)
[domain]/somethingelse -> [domain]/somethingelse (showing the query.php page with ?somethingelse appended)
htaccessの
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ query.php?$1 [L]
実際のテスト:
グッド
[domain]/pricing.php -> [domain]/pricing (showing the pricing.php page)
[domain]/pricing -> [domain]/pricing (showing the pricing.php page)
悪い
[domain]/somethingelse -> [domain]/somethingelse (showing the query.php page with ?somethingelse_php appended)
私は上記の持っている.htaccessファイルには、私は$ _GET変数を吐き出すときにそれをquery.phpにリダイレクトする場合、それ以外はしたいすべてが「_php」を示してい添付。私は以前のルールのために推測しています...
ロケットの回答エルは良いです。他のルールの一番上に置く: #index.phpに再ルーティングする RewriteCond%{REQUEST_URI} ^/$ RewriteRule ^(。*)$/index.php [L] – jasondeegan