Php 如何使用.htaccess mod_rewrite来更改以下内容
如何使用Mod_Rewrite更改以下URLPhp 如何使用.htaccess mod_rewrite来更改以下内容,php,.htaccess,codeigniter,mod-rewrite,Php,.htaccess,Codeigniter,Mod Rewrite,如何使用Mod_Rewrite更改以下URL main/order/$var to/$var 我已经在使用.htaccess将/.index.php/$var重写为/$var。这是一个codeigniter设置。因此,完整的URL应该是/.index.php/main/order/$var 这是我当前的文件: RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|stats) RewriteRule ^(.
main/order/$var to/$var
我已经在使用.htaccess将/.index.php/$var
重写为/$var
。这是一个codeigniter设置。因此,完整的URL应该是/.index.php/main/order/$var
这是我当前的文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|stats)
RewriteRule ^(.*)$ /index.php/main/order/$1 [L]
尝试调整此文件时,我收到一个错误配置错误。我很困惑,您声称发布了
.htaccess
样式文件的工作版本,但这看起来更像是您的尝试。RewriteRule
中的index.php
在我看来很有趣(但我不太了解codeigniter),它当然不应该同时出现在RewriteCond
和RewriteRule
中
您的RewriteRule
看起来不错,但我建议使用RewriteCond
:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(index\.php|images|robots\.txt|css|js|stats)
RewriteRule ^(.*)$ /index.php/main/order/$1 [L,QSA]
这是一个独特的codeigniter场景。我使用以下.htaccess实现此功能:
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots\.txt|css|js|stats)
RewriteRule ^(.*)$ /index.php/$1 [L]
然后我必须按如下方式配置routes.php
$route['main'] = 'main/order';
$route['(:any)'] = 'main/order/$1';
好吧,既然你说它有效,你只想修改它,为什么不扩展现有的模式呢。你已经知道怎么做了。如果你真的在这里有一个特定的问题,那么就说出它的名字。并请发布您的现有代码。添加了当前文件。很抱歉没有包括预付款。谢谢抱歉,但这肯定不是
.htaccess
样式文件的工作版本RewriteCond$1
毫无意义。$1
在这里的意思是什么?在使用上面的代码时,我收到一个500内部服务器错误。apache日志中的错误:AH00124:由于可能的配置错误,请求超出了10个内部重定向的限制。如有必要,使用“LimitInternalRecursion”增加限制。使用“LogLevel debug”获取回溯。很抱歉,我确实忘记了条件中的index.php
是防止这种重定向循环所必需的。现在应该可以工作了:-)我仍然不能理解重写cond的意思,但是无论如何,如果它能满足你的需要,那就太好了!