htaccess的重写,在一个数组? [英] htaccess rewrite, in an array?

查看:108
本文介绍了htaccess的重写,在一个数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有以下页面:

http://www.site.com/folder/page.php?id=89
http://www.site.com/folder/page.php?id=85
http://www.site.com/folder/page.php?id=camel+hump
http://www.site.com/folder/page.php?id=76
http://www.site.com/folder/page.php?id=71
http://www.site.com/folder/page.php?id=frog
http://www.site.com/folder/page.php?id=62
http://www.site.com/folder/page.php?id=59

和我想直接如下:

89,79,44,骆驼+驼峰以下网页:

89, 79, 44, camel+hump to the following page:

http://www.site.com/folder/page/$1

例如:

http://www.site.com/folder/camel-hump (Notice the + replaced with a -)

和其他一切以下网页:

http://www.site.com/folder/overview

我将如何做到这一点?

How would I do this?

基本上,我有需要重定向约200页,并且它们都具有相同的URL除了GET参数,其中一些需要重定向到一个 /文件夹/获取参数页,其余的需要重定向到 /文件夹/概述页。

Basically, I have around 200 pages that need redirecting, and they all have the same URL apart from the get parameter, some of them need redirecting to a /folder/get-parameter page and the rest need redirecting to a /folder/overview page.

我还需要+号与被替换 - 标志,因此,例如骆驼+驼峰变成骆驼的驼峰

I also need + signs to be replaced with - signs, so for example camel+hump becomes camel-hump

我如何能做到这一点的,重写规则?是这样的:

How can I do this with a rewrite rule? Something like:

if match (89|79|44|camel+hump|frog) go to /folder/$1 (but replace + with -)

一切,去 /文件夹/概述

感谢您

推荐答案

尝试:

# Filter out the query string values for id that you want to rewrite
RewriteCond %{QUERY_STRING} ^id=(89|79|44|camel\+hump|frog)
RewriteRule ^folder/page.php$ /folder/page/%1?  [L]

# get rid of the +
RewriteRule ^folder/page/(.+)\+(.+)$ /folder/page/$1-$2 [L]

这篇关于htaccess的重写,在一个数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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