正在使用.htaccess删除部分链接地址


Removing part of a link address with .htaccess

你好,这是我目前为止的.htaccess文件。

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    Options -Indexes
    RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] 

我当前的URL是类别/节目/音乐

如何使用htaccess将其转换为类别/音乐?我想删除显示/

感谢您的帮助!

假设这是整个文件,则url category/show/music将重写为index.php?url=category/show/music。以下重写将为索引页"插入"显示。然而,编辑index.php将是更明智的。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Options -Indexes
RewriteRule ^(.*)/(.*)$ index.php?url=$1/show/$2 [L,QSA] 

RewriteEngine on行下方插入此规则:

RewriteRule ^(category)/show/(.+?)/?$ /$1/$2 [L,R=301,NC]