在URL中使用的htaccess的末尾删除尾随字符 [英] Removing a trailing character at the end of a URL using htaccess

查看:233
本文介绍了在URL中使用的htaccess的末尾删除尾随字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址:
www.example.com/tattoo-ink-radiant-colors-teal /

I have a url: www.example.com/tattoo-ink-radiant-colors-teal/

我需要它更改为

www.example.com/ink-wineberry /

www.example.com/ink-wineberry/

到目前为止,我有

在我的htaccess下面作为一个临时的解决办法

the following in my htaccess as a temporary fix

RewriteEngine On
RewriteBase /
RewriteCond   %{REQUEST_FILENAME} !-f
RewriteCond   %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ink
RewriteRule -1oz/ /ink [R=301,L]

编辑*,使其更简单这里有几个例子

edit* to make it simpler here are a few more examples

纹身油墨的辐射为主色调,水鸭1盎司/应该是纹身油墨的辐射,颜色,青色/

tattoo-ink-radiant-colors-teal-1oz/ should be tattoo-ink-radiant-colors-teal/

纹身油墨的辐射,超白1盎司/应该是纹身油墨的辐射,超白/

tattoo-ink-radiant-super-white-1oz/ should be tattoo-ink-radiant-super-white/

推荐答案

这是确定有:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)-1oz/?$ $1/ [R=301,L]

这篇关于在URL中使用的htaccess的末尾删除尾随字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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