开发者

Redirect a URL based off it's first character with htaccess

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 ex开发者_Python百科ample 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

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.


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜