私の.htaccessファイルではなく、PHPの中からmodリライトを処理できるようにしたいのですが、新しい書き換えが必要なカスタムモジュールを持っているときに.htaccessをやり直す必要はありませんファイル。mod_rewriteのルールをPHPのルールに変える
私はWordPressがある彼らの.htaccessないという方法を模倣したい:
RewriteEngine On RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
私の現在の.htaccessファイルは、このです:
Options +FollowSymlinks
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# MBP Rules
RewriteRule ^module/([A-Za-z-_]+)/([A-Za-z-_]+)/?$ /index.php?p=module&prefix=$1&module_page=$2 [NC,QSA,L]
RewriteRule ^module/([A-Za-z-_]+)/([A-Za-z-_]+)/([A-Za-z-_]+)/?$ /index.php?p=module&prefix=$1&module_page=$2&page=$3 [NC,QSA,L]
RewriteRule ^module/([A-Za-z-_]+)/([A-Za-z-_]+)/([0-9]+)/?$ /index.php?p=module&prefix=$1&module_page=$2&id=$3 [NC,QSA,L]
RewriteRule ^([A-Za-z-_]+)/?$ /index.php?p=$1 [NC,QSA,L]
RewriteRule ^([A-Za-z-_]+)/([A-Za-z-_]+)/?$ /index.php?p=$1&s=$2 [NC,QSA,L]
RewriteRule ^([A-Za-z-_]+)/([A-Za-z-_]+)/([0-9]+)/?$ /index.php?p=$1&s=$2&id=$3 [NC,QSA,L]
誰もこれを実現するために方法を知っていますか?
PHPが呼び出される前に、Apacheの書き換えが実行/実行されることに留意してください。サブページなどを動的にインクルードする場合を除き、せいぜい本格的なhttp 301/302リダイレクトを行う必要があります。 –