.htaccess htaccess mod rewrite需要重写

.htaccess htaccess mod rewrite需要重写,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,将mydomain.ru重定向到mydomain.ru/rus 如果我写: RewriteCond %{HTTP_HOST} !^mydomain\.ru/rus/$ [NC] RewriteRule ^(.*)$ http://mydomain.ru/rus/$1 [R=301,L] 当我有一个无尽的重定向。有什么想法吗?在这两种情况下,主机都是mydomain.ru,这就是为什么您将得到无休止的重定向 请尝试以下方法: RewriteCond %{REQUEST_URI} !^/rus/

mydomain.ru
重定向到
mydomain.ru/rus

如果我写:

RewriteCond %{HTTP_HOST} !^mydomain\.ru/rus/$ [NC]
RewriteRule ^(.*)$ http://mydomain.ru/rus/$1 [R=301,L]

当我有一个无尽的重定向。有什么想法吗?

在这两种情况下,主机都是mydomain.ru,这就是为什么您将得到无休止的重定向 请尝试以下方法:

RewriteCond %{REQUEST_URI} !^/rus/
RewriteRule ^(.*)$ rus/$1
这将检查您当前是否正在浏览rus文件夹中的内容,如果没有,则将您重定向到该子文件夹