如何用.htaccess更改URL中的字母大小写?

时间:2015-05-25 14:24:45

标签: php apache .htaccess mod-rewrite

我在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出了什么问题? 另外,在第一个RewriteRule较低的情况下移动该行会导致"内部服务器错误"。

我的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]

1 个答案:

答案 0 :(得分:1)

我认为你的" myAction" URL组件可能是与[DPI]标志相关的错误/问题。你有没有在rewriterules上尝试过?

默认情况下,PATH_INFO会溢出并恢复。但是,如果你捕捉并附加它,就像你一样,你最终会重复。