htaccess的第一个文件夹不能正常工作与破折号 [英] in htaccess first folder is not working with dashes

查看:117
本文介绍了htaccess的第一个文件夹不能正常工作与破折号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网址是这样的: http://example.com/apple_a/

我使用这个规则:

RewriteEngine On  
RewriteRule ^([^_]*)-+(.*)$ $1_$2 [L,NC]

这是取代其他网址如 http://example.com/apple/a_a/a_b http://example.com/apple/aa/ab (下划线与破折号),但是当我在这样的第一个目录写_ http://example.com/apple- A / AA / ,那么它抛出404错误。

this is replacing other URL's like http://example.com/apple/a_a/a_b to "http://example.com/apple/a-a/a-b" (underscore with dashes) but when I write "_" in first directory like this "http://example.com/apple-a/a-a/" then its throwing 404 error.

所以,我希望这样的工作不知何故。请大家帮帮忙。

So I wants that working somehow. Please help.

推荐答案

正确的规则将是:

RewriteEngine On  
RewriteRule ^([^-]*)-+(.*)$ $1_$2 [L,NC]

([^ _ *)而不是([^ ​​- ] *)

这篇关于htaccess的第一个文件夹不能正常工作与破折号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆