基于URL到一个新的页面的RewriteCond重写规则进行的.htaccess,定期EX pression(RewriteCond RewriteRule for .htaccess based on URL to a new page, regular expression)

   IT问题网   2018-12-07 00:00:00

问 题

我有一个有趣的重写规则,我不知道做正规ex pression。

总之,我想检查后的url中的第二个/- 基于内容的,可能是前进

它归纳到这两个规则:

  1. 如果重定向后的第二/字符串包含任何信件
  2. 重定向如果字符串之后第二个/长于7个字符

下面举例说明:

http://www.mysite.org/section/subsection/2011 ( ok,什么都不做)

http://www.mysite.org/section/subsection/2011-11 (好吧,什么都不做)

http://www.mysite.org/section/subsection/2011- 11-09 (也不行,重定向)

http://www.mysite.org/section/subsection/2011- 11-w1 (也不行,重定向)

请帮我重写规则和重写电导率

解决方案

我基于以下的正则表达式掉你的例子这似乎一切都进行分析后,最后一个'/',而不是第二。

/ [^ a-za-z] {1,7} $
 

在简单的英语,这正则表达式匹配一组字符遵循一个"/",其中包含1-7非字母字符。使它只匹配最后'/'我所附一个'$',其中行的末尾匹配。

此外,由于你正在处理的url,你可能要加上"/?"在"$"的情况下,之前有一个悬空'/'结尾。

/ [^ a-za-z] {1,7} / $?
 

我希望这回答了你的问题。

标签:基于一个页面重写规则进行定期按期



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

的.htaccess,mod_rewrite的,正则表达式用目录和文件类型(.htaccess, mod_rewrite, regex with directory and filetype)

problem i want to do a rewrite with the following conditi ...

.htaccess的语言重定向310错误(Htaccess language Redirect 310 error)

problem i have a two language site swedish sidewww.site ...

重定向一切的index.php(Redirection everything to index.php)

problem i wan't to redirect everything to index.php exepe ...

生成SE友好的URL的.htaccess国防部重写(Generating SE friendly URL .htaccess mod rewrite)

problem i've a url which get file name through get method ...

htaccess的子域名重定向(htaccess subdomain redirect)

problem i've searched around and tried a few ...

UrlRewrite 3 GET请求(UrlRewrite with 3 get request)

problem i'm working on a project and stuck on urlrewrite. ...

mod_rewrite的:恶意重定向(Mod_ReWrite: Unwanted redirect)

problem possible duplicate: .htaccess, clean ...

限制用户子目录(limiting users to subdirectories)

problem i have a subdirectory of users that i want to lim ...

重定向子文件夹的.htaccess(Redirection Subfolder Htaccess)

problem i want a redirect using htaccess i have a post na ...

使用的.htaccess,从来没有表现出的index.php(Using .htaccess, never show index.php)

problem how can i never show index.phpfor example, all re ...

在子域的内部服务器错误(internal server error in subdomains)

problem i installed worpress to my main domain abcd.com. ...

基于用户代理手机网站重定向(Mobile website redirection based on user agent)

problem say i've got two distinct domains: ...

的Joomla htaccess的不工作(Joomla htaccess not working)

problem i am using joomla 1.7 and using joomla's built in ...

扩大友好的URL,国防部重写(Expanding friendly url, mod rewrite)

problem i am using modx, which is a cms system. it has a ...

共享主机Zend的项目?(zend project on shared hosting )

problem i created a zend project on localhost on ubuntu o ...

URL结构的htaccess(url construction htaccess)

problem lets say i have a link to one of my page that loo ...

htaccess的重写规则(.htaccess RewriteRule)

problem i'm trying to write a rewriterule (with no luck) ...

如何配置.htaccess文件的重写规则摆脱扩展,尾随斜线,WWW?(How to configure .htaccess file for rewrite rules to get rid of extensions, trailing slashes, www)

problem this is what i want - when somebody enters site. ...

htaccess的基础上与通配符和东西后,到index.php index.php页面重定向不存在的页面(.htaccess redirect non existing pages based on index.php page with wildcard and something after it to index.php)

problem please help, some website is arbitrar ...

国防部重写的子域子域目录(mod-rewrite subdomain to subdomain dir)

problem i have a bit of a problem with rewrite rules; so ...