6

実際のファイルやディレクトリではないリクエストをindex.phpファイルにリダイレクトできる単純なmod_rewriteルールがあります

    Options +SymLinksIfOwnerMatch 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

PHPファイルで、このナビゲーションを処理するためにこの単純なコードを入れました

<?php
$navString = $_SERVER['REQUEST_URI']; // Returns "/Mod_rewrite/edit/1/"
$parts = explode('/', $navString); // Break into an array
// Lets look at the array of items we have:
print_r($parts);
?>

私の開発環境は XAMPP と Windows 7 です - 64 ビット httpd.conf ファイル

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory>

<Directory "C:/xampp/cgi-bin">
    AllowOverride All
    Options None
    Order allow,deny
    Allow from all
</Directory>

私の問題は、たとえばスクリプトに変数を渡すときです

http://locahost/test/somethinghere/andhere

それは私をローカルホストのデフォルトページにリダイレクトします

http://locahost/xampp
4

3 に答える 3

4

フォルダーを .htaccess に追加して Options +SymLinksIfOwnerMatch を削除するだけで解決しました

RewriteBase /test/
于 2012-09-05T00:32:21.117 に答える