komrad
komrad

Reputation: 3

Removing a trailing character at the end of a URL using htaccess

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/

Upvotes: 0

Views: 101

Answers (1)

Croises
Croises

Reputation: 18671

It's ok with:

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

Upvotes: 1

Related Questions