首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.htaccess mod_rewrite规则独立工作,但不能协同工作

.htaccess mod_rewrite规则独立工作,但不能协同工作
EN

Stack Overflow用户
提问于 2013-10-03 02:29:34
回答 1查看 66关注 0票数 0

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

第一种是用语言代码重定向urls (网站现在只有一种语言):

代码语言:javascript
复制
RewriteRule ^en/(.*)$ /$1 [R=301,L]
RewriteRule ^es/(.*)$ /$1 [R=301,L]

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

第二个是为了seo目的而更具描述性:

/社区/

/教师和学生/

代码语言:javascript
复制
RewriteCond %{REQUEST_URI} ^.*/community.*$
RewriteRule .*  /tutors-and-students    [L,R=301,DPI]

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

第三个更改配置文件urls:

/community/myprofile/username

/tutors-and-students/用户名

代码语言:javascript
复制
RedirectMatch permanent myprofile(.*) http://www.profr.org/tutors-and-students/$1

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

它们都是独立工作的,但不是协同工作的:

代码语言:javascript
复制
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

感谢你的提示。

EN

回答 1

Stack Overflow用户

发布于 2013-10-03 02:44:51

你应该坚持使用mod_rewrite,而不是将它与来自mod_alias的重定向混合在一起:

代码语言:javascript
复制
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]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19144120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档