基于重定向过的URL它与htaccess的第一个字符第一个、它与、重定向、字符

2023-09-02 10:03:25 作者:剪个平头一生骄傲*

所以,我有一个问题,即我试图重定向基于是否开始于一个特定号码的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