如何使用.htaccess中的RewriteRule重定向到清除URL(删除最后的超级用户)

时间:2022-04-25 07:56:36

I am trying to create a clean URL using a RewriteRule in an .htaccess file.

我正在尝试使用.htaccess文件中的RewriteRule创建一个干净的URL。

Using a hypothetical example, I would like this:

使用一个假设的例子,我想这样:

"article0/news/Prints-Ads-newspapers-and-magazines-"

"article1/news/true-love-"

"article2/news/fire-storm-"

"article3/news/nba-news-"

To redirect to :

要重定向到:

"article0/news/Prints-Ads-newspapers-and-magazines"

"article1/news/true-love"

"article2/news/fire-storm"

"article3/news/nba-news"

I need to remove the last hypen from this urls

我需要删除此网址中的最后一个

1 个解决方案

#1


It is very simple

这很简单

RewriteEngine on
RewriteRule ^(.*)-$ /$1 [L]

#1


It is very simple

这很简单

RewriteEngine on
RewriteRule ^(.*)-$ /$1 [L]