Mod rewrite 简单Apache重写

Mod rewrite 简单Apache重写,mod-rewrite,rewrite,Mod Rewrite,Rewrite,各位 这很容易,但我似乎无法做到这一点,任何帮助感谢 如果有人访问某个URL,我会很高兴 http://test.api.com/somestuff I want it to redirect to http://test.api.com/en/api/somestuff 然而,我的重写规则不断导致无休止的重定向-有人能发现错误吗 RewriteCond %{REQUEST_URI} !^(/en/api/).* RewriteRule ^(.*)$ http://%{HTTP_HOST}/

各位

这很容易,但我似乎无法做到这一点,任何帮助感谢

如果有人访问某个URL,我会很高兴

http://test.api.com/somestuff I want it to redirect to 
http://test.api.com/en/api/somestuff
然而,我的重写规则不断导致无休止的重定向-有人能发现错误吗

RewriteCond %{REQUEST_URI} !^(/en/api/).*
RewriteRule ^(.*)$ http://%{HTTP_HOST}/en/api/$1 [R,L]
试试这个(RewriteRule正则表达式中的斜杠是主要区别):

RewriteCond %{REQUEST_URI} !^/en/api/.*
RewriteRule ^/(.*)$ http://%{HTTP_HOST}/en/api/$1 [R,L]