URLを変更せずに、すべてのhtmlまたはphp URLにindex.phpを表示します
元。ユーザー タイプの anything-everything.html(.php) は、URL を変更せずに index.php を表示します。
状態 - ホストに any-everything.html(.php) が存在しない
URLを変更せずに404リダイレクトのように
SOへようこそ。Web サイトを Apache Web サーバーで実行している場合は、Apache モジュール mod_rewriteを使用してこれを実現できます。.htaccess
Web サイトのルートに配置する必要があるファイルの例を次に示します。
# switch on mod_rewrite
RewriteEngine On
# redirect all non-www request to www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# rewrite all physical files and folders
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
# add all exceptions that should not be redirected
RewriteCond %{REQUEST_URI} "/layout/" [OR]
RewriteCond %{REQUEST_URI} "/javascript/" [OR]
RewriteCond %{REQUEST_URI} "/content"
# and finally pass everything to the index.php as a parameter
RewriteRule .* - [L]
RewriteRule (.*) index.php?value=$1 [QSA]
これにより、次のことが行われます。
$_GET['value']
を保持しhello/world.html
、さらに処理することができますApache rewrite を使用します (Apache を使用していて、サーバーにアクセスできる場合)。index.php へのすべてのパスを書き換える Apacheからのレシピは問題ないはずです。