本当に必要なのは、デフォルトのタイプでの「振り返り」のサポートです。次のように Apache 仮想ホスト (何か) をセットアップします。
<VirtualHost *:80>
ServerName example.com:80
ServerAlias www.example.com
DocumentRoot "/path/to/root/dir"
AddDefaultCharset UTF-8
ErrorDocument 403 "/403.php"
ErrorDocument 404 "/404.php"
<Directory /path/to/root/dir>
Options Indexes FollowSymLinks
DefaultType application/x-httpd-php
AllowOverride All
Order deny,allow
Allow from all
AddOutputFilterByType DEFLATE application/javascript text/css text/html text/plain text/xml
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !.index.ph.*
RewriteRule ^(.*)$ /index.php
</Directory>
</VirtualHost>
重要な行は です。これは、ファイル拡張子DefaultType application/x-httpd-php
を取り除くことができることを意味します。.php
http://example.com/this_is_a_php_page
のような URL を使用できるようになりhttp://example.com/this_is_a_php_page/with_a_path_info_var
ました。
したがって、on this_is_a_php_page
(実際には拡張子のない .php ファイル) を使用$_SERVER['PATH_INFO']
して、URI で渡される および vars をチェックできます。
編集:RewriteEngine
すべてを にプッシュする and ルールを
追加しましたindex.php
。これは、呼び出されたサーバー上に (実際の) 単一のページがあり、実際に要求されたものについて varindex.php
をチェックする必要があることを意味します。$_SERVER['REDIRECT_URL']
たとえば、 へのリクエストはに渡されてhttp://example.com/a_page
ロードされるようになりました。注: このソリューションは、すべてを index.php にプッシュします。次のような例外を含める必要があります。index.php
a_page
$_SERVER['REDIRECT_URL']
RewriteCond %{REQUEST_FILENAME} !.not_me_plz.*
files で始まるすべてのファイルをnot_me_plz
「期待どおり」に提供できるようにします。