Removing a trailing character at the end of a URL

2019-09-04 06:03发布

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

I need it to change to

www.example.com/ink-wineberry/

so far I have

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

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

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

1条回答
可以哭但决不认输i
2楼-- · 2019-09-04 06:47

It's ok with:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)-1oz/?$ $1/ [R=301,L]
查看更多
登录 后发表回答