.htaccess mod_重写规则独立工作,但不能一起工作

.htaccess mod_重写规则独立工作,但不能一起工作,.htaccess,mod-rewrite,http-status-code-301,.htaccess,Mod Rewrite,Http Status Code 301,我正在尝试在.htaccess中设置一些url重写 第一种是使用语言代码重定向URL(站点现在使用一种语言): ======================== 第二个是为了搜索引擎优化的目的更具描述性: /社区/ 到 /教师和学生/ RewriteCond %{REQUEST_URI} ^.*/community.*$ RewriteRule .* /tutors-and-students [L,R=301,DPI] =================================

我正在尝试在.htaccess中设置一些url重写

第一种是使用语言代码重定向URL(站点现在使用一种语言):

========================

第二个是为了搜索引擎优化的目的更具描述性:

/社区/

/教师和学生/

RewriteCond %{REQUEST_URI} ^.*/community.*$
RewriteRule .*  /tutors-and-students    [L,R=301,DPI]
=================================

第三个更改配置文件URL:

/社区/myprofile/username

/导师和学生/用户名

RedirectMatch permanent myprofile(.*) http://www.profr.org/tutors-and-students/$1
=========================

它们都是独立工作的,但不是一起工作的:

RewriteRule ^en/(.*)$ /$1 [R=301,L]
RewriteRule ^es/(.*)$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^.*/community.*$
RewriteRule .*  /tutors-and-students    [L,R=301,DPI]
RedirectMatch permanent myprofile(.*) http://www.profr.org/tutors-and-students/$1

感谢您的提示。

您应该坚持使用mod_rewrite,而不是将其与mod_alias的重定向混合使用:

RewriteRule ^en/(.*)$ /$1 [R=301,L]
RewriteRule ^es/(.*)$ /$1 [R=301,L]

RewriteRule ^.*/?community /tutors-and-students [L,R=301,DPI]

RewriteRule ^.*/?myprofile(.*)$ /tutors-and-students/$1 [L,R=301]

当你说不工作时,你到底面临什么问题?最后一条规则对使用/myprofile/重定向URL没有任何作用。在本例中,请尝试使用新的浏览器进行测试。在这个目录中,你是否将.htaccess?hm-放在上面?这并没有完全破解它。网站管理员工具告诉我,我有404个URL,如下所示:/en/community/myprofile/1565 joshua oganga,何时应该重定向到/tutors and students/1565 joshua oganga。取而代之的是教师和学生。有什么想法吗?@larpo你需要改变“社区”和“我的档案”规则,因为社区一号首先匹配/en/**community**/myprofile/1565 joshua oganga。但我猜你对社区的意思只是这个URL<代码>/en/社区?然后将社区正则表达式更改为:
^.*/?community/?$
谢谢-此url仍然不起作用-它是404-/community/822 ratna ventrapragada-现在的条件是:RewriteRule^en/(.*)$/$1[R=301,L]RewriteRule^es/(.*)$/$1[R=301,L]RewriteRule^.*/?myprofile(.$/导师和学生/$1[L,R=301]重写规则^.*/?社区/?$/导师和学生[L,R=301,DPI]
RewriteRule ^en/(.*)$ /$1 [R=301,L]
RewriteRule ^es/(.*)$ /$1 [R=301,L]

RewriteRule ^.*/?community /tutors-and-students [L,R=301,DPI]

RewriteRule ^.*/?myprofile(.*)$ /tutors-and-students/$1 [L,R=301]