我在我的.htaccess以下規則:的Apache的環境變量沒有mod_rewrite的規則設定
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php$
RewriteRule ^(.*)$ index.php?q=$1 [L]
</IfModule>
此查詢字符串值q
設置爲請求URI(就是那個索引之前剝離前述任一目錄.php駐留在)。例如:http://localhost/framework/testing
組q=testing
。
我想改變這個,以便設置一個查詢字符串,而不是設置一個環境變量。我曾嘗試以下,但它不工作(環境VAR不被設置):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php$
RewriteRule ^(.*)$ index.php [ENV=request:$1,L]
</IfModule>
奇怪的是,環境VAR將設置如果請求與index.php文件開始,例如:http://localhost/framework/index.php/testing
套q=index.php/testing
你可以檢查你的答案現在有效;) –
我想;它回答了我問的問題,但它不適用於別名的URL(共享ssl)。我的目標是不必在我的PHP中指定一個基本的URL。 –
這麼好,錯......修改你的問題,或檢查這個有效,也許問另一個? –