未在mod_重写规则中设置Apache环境变量
我的.htaccess中有以下规则:未在mod_重写规则中设置Apache环境变量,apache,mod-rewrite,Apache,Mod Rewrite,我的.htaccess中有以下规则: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1 !^index\.php$ RewriteRule ^(.*)$ index.php?q=$1 [L] </IfModule> <IfModule mod_rewrite.c> RewriteEngine on RewriteCond $1 !^index\.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php$
RewriteRule ^(.*)$ index.php?q=$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
奇怪的是,如果请求以index.php开头,就会设置环境变量,例如:http://localhost/framework/index.php/testing
设置q=index.php/testing
使用路径信息(正如@chrono所建议的)和稍微不同的mod\u重写规则,我已经按预期工作了
修改。htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php$
RewriteRule ^(.*)$ index.php?q=$1 [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^index\.php
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
重新启动发动机
1美元^索引\.php
重写规则^(.*)$index.php/$1[L]
您现在可以检查您的答案是否有效;)我想;它回答了我问的问题,但它不适用于别名URL(共享ssl)。我的目标是不必在PHP中指定基本URL。。。修改您的问题,或者检查此问题是否有效,或者询问其他问题?