我对apache中的mod_rewrite有问题[服务器版本:apache/2.4.6(ubuntu)][服务器版本:2014年3月19日20:56:01]
我正在处理用php codeigniter编写的带有这样一个.htaccess的项目:
RewriteEngine on
RewriteBase /my_dir/
RewriteRule (.*)test/myAction(.*) $1Test/myAction$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm
AddType video/mov .mov
因此,我想把http://example.com/my_dir/test/myAction改为http://example.com/my_dir/Test/myAction(大写字母T在我的控制器名中)]。
它在windows 8上工作。可能是因为Windows根本忽略了字母的情况。但是如何让它在linux上工作呢?我的.htaccess怎么了?
另外,在第一个重写规则较低的情况下移动行,会导致“内部服务器错误”。
我的error.log显示如下:
rewrite 'test/myAction' -> 'Test/myAction'
rewrite 'Test/myAction/myAction' -> 'index.php/Test/myAction/myAction'
forcing '/var/www/my_dir/index.php/Test/myAction/myAction' to get passed through to next API
trying to replace prefix /var/www/my_dir/ with /my_dir/
internal redirect with /my_dir/index.php/Test/myAction/myAction [INTERNAL REDIRECT]
pass through /var/www/my_dir/index.php
rewrite 'Test/myAction/myAction' -> 'index.php/Test/myAction/myAction'
forcing '/var/www/index.php/Test/myAction/myAction' to get passed through to next API URI-to-filename handler
strip document_root prefix: /var/www/index.php/Test/myAction/myAction -> /index.php/Test/myAction/myAction
internal redirect with /index.php/Test/myAction/myAction [INTERNAL REDIRECT]
最佳答案
我认为“myaction”url组件加倍可能是与[dpi]标志相关的bug/问题。你试过重写规则吗?
默认情况下,路径信息溢出并还原。但是如果你像你一样捕捉并附加它,你最终会得到一个重复。