基于重定向过的URL它与htaccess的第一个字符 [英] Redirect a URL based off it's first character with htaccess

查看:130
本文介绍了基于重定向过的URL它与htaccess的第一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个问题,即我试图重定向基于是否开始于一个特定号码的URL。我需要重定向网站访问者,如果尾随URL的第一个字符开头的数字1,那么我需要删除URL的数量1,然后用一个特定的目录路径替换1。

So I have a problem in which I'm attempting to redirect a URL based on whether or not it begins with a certain numbers. I'm needing to redirect a site visitor if the first character of the trailing URL begins with the number "1", then I need to remove the number 1 of the URL and then replace the 1 with a specific directory path.

所以这里有一个具体的例子来阐明。如果用户点击(或在浏览器的地址栏中类型)

So here's a specific example to clarify. If the user clicks on (or types in their browser's address bar)

http://www.example.com/1d39g

,他们将被自动重定向到

they would automatically be redirected to

http://www.example.com/product/d39g

另外一文不值,他们此URL个体打字会读它关闭一个标签的邮件,他们不会总是被点击的链接。我原本以为通过的jQuery这样做的,但我想的.htaccess将接近这一目标的最佳途径。

Also worth nothing, they individual typing in this URL will be reading it off a label in the mail, they won't always be clicking on a link. I originally had thought of doing this through jQuery, but I thought .htaccess would be the best way to approach this.

推荐答案

激活mod别名,然后加入到这一点你的.htaccess

Activate the mod alias, then add this into your .htaccess

RedirectMatch /1(.*)$ /product/$1

这篇关于基于重定向过的URL它与htaccess的第一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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