【问题标题】:Removing a trailing character at the end of a URL using htaccess使用 htaccess 删除 URL 末尾的尾随字符
【发布时间】:2015-02-10 16:30:56
【问题描述】:

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

我需要把它改成

www.example.com/ink-wineberry/

到目前为止我有

我的 htaccess 中的以下内容作为临时修复

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

edit* 让它更简单,这里还有几个例子

tattoo-ink-radiant-colors-teal-1oz/ 应该是 tattoo-ink-radiant-colors-teal/

tattoo-ink-radiant-super-white-1oz/ 应该是 tattoo-ink-radiant-super-white/

【问题讨论】:

  • ink-wineberry 是动态文本还是静态文本?

标签: wordpress apache .htaccess server


【解决方案1】:

没关系:

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

【讨论】:

  • 谢谢,但我需要一些更有活力的东西。我有多种产品需要从 tattoo-ink-radiant-colors-wineberry-1oz/ 更改为 tattoo-ink-radiant-colors-wineberry/ 或 tattoo-ink-radiant-colors-teal-1oz/ 更改为 tattoo-ink -radiant-colors-teal/
猜你喜欢
  • 1970-01-01
  • 2016-04-13
  • 2012-12-13
  • 1970-01-01
  • 2012-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多