首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >htaccess和minus在url中不起作用

htaccess和minus在url中不起作用
EN

Stack Overflow用户
提问于 2013-06-20 17:00:43
回答 1查看 219关注 0票数 0

当url为www.xxx.com/theproblem/is-here.html时。我想要得到is-here.html,但是有了这个规则...

代码语言:javascript
复制
RewriteRule ^([a-z\-\_A-Z0-9]+)/([^/]+)?(?<!\.html)\b/?(([^/]+)\.html)?$ this.php?param1=$1&param2=$2&param3=$3

param3的...the返回值为here.html。这是因为参数2得到了is-

为什么会发生这种情况?

我想实现这个目标:

代码语言:javascript
复制
www.xxx.com/theproblem/is-here.html. -> param1=theproblem | param2=is-here.html
www.xxx.com/theproblem/why-this/ -> param1=theproblem | param2=why-this
www.xxx.com/theproblem/why-this/is-here.html. -> param1=theproblem | param2=why-this | param3=is-here.html

我该怎么做呢?

EN

回答 1

Stack Overflow用户

发布于 2013-06-20 17:43:11

试试这段代码。这可能不是您想要的(在正则表达式级别),但这是有效的:

代码语言:javascript
复制
RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/([^.].html)$ this.php?param1=$1&param2=$2&param3=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/$ this.php?param1=$1&param2=$2 [L]
RewriteRule ^([^/]+)/([^.].html)$ this.php?param1=$1&param2=$2 [L]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17209449

复制
相关文章

相似问题

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