URL RewriteMap指令阿帕奇 [英] URL rewritemap apache

查看:207
本文介绍了URL RewriteMap指令阿帕奇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty新的节目,并遇到了以下问题。请您告诉我。

I am pretty new to programming, and have encountered the following problem. Please kindly advise me.

我有像 www.mysite.com/products.php?cid=3 A URL网站
其中从后端数据库中生成的参数 CID (3这里)的值,并且可以是一个从1至3个

I have a website with a URL like www.mysite.com/products.php?cid=3 where the value of the parameter cid (3 here) is generated from a backend database, and can be a number from 1 to 3.

我想阿帕奇重写URL,因此:

I would like Apache to rewrite the URL, so that:

www.mysite.com/nike 将重定向到 www.mysite.com/products.php?cid=1

www.mysite.com/reebok 将重定向到 www.mysite.com/products.php?cid=2

www.mysite.com/kswiss 将重定向到 www.mysite.com/products.php?cid=3

等等......

我有一个名为的文本文件的 category.txt 的根目录包含以下内容下:

I have a text file named category.txt under the root directory with the following content:

nike 1 
reebok 2 
kwiss 3 

和的.htaccess

and .htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 
rewritemap categorymap txt:/image/categorymap.txt 
RewriteRule ^(.*) /products.php?cid=${categorymap:$1|NOTFOUND} [PT] 
</IfModule> 

本,但不能正常工作,请告诉我,

This, however does not work, please advise me,

推荐答案

RewriteMap指令指令只能在任一服务器或虚拟主机的配置中。你需要有定义。如果您没有访问任一服务器或虚拟主机的配置,那么你只需要列举所有那些为单独的改写指令像:

The RewriteMap directive can only be used in either server or vhost config. You'll need to define it there. If you don't have access to either server or vhost config, then you'll just need to enumerate all of those into individual rewrite directives like:

RewriteRule ^nike$ /products.php?cid=1 [L,QSA]
RewriteRule ^reebok$ /products.php?cid=2 [L,QSA]
RewriteRule ^kswiss$ /products.php?cid=3 [L,QSA]

这篇关于URL RewriteMap指令阿帕奇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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