将所有以子字符串开头的 URL 重定向到 Joomla 3.x 中的新 url

Redirect all URLs starting with a substring to a new url in Joomla 3.x

我不得不重新设计一个 Joomla 列表网站,该网站使用一个组件来显示列表。各项目的url如下

示例。com/gulf-job-listing/jobs/items/view/xxxxx

xxxx 通常是 id 和 alias 的组合,所以可能是这样的

示例。com/gulf-job-listing/jobs/items/view/1-programmer

无论如何,我想做的是,将所有 url 示例重定向到 com/gulf-job-listing/jobs/items/view/xxxxx 例如。com/gulf-job-listing

我尝试使用 Joomla 核心重定向,但我只能将一个 url 重定向到另一个。即我将 example.com/gulf-job-listing/jobs/items/view/ 重定向到 example.com/gulf-job-listing

我的.htaccess文件如下

Options +FollowSymLinks
Options -MultiViews

RewriteEngine On



RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]

RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

RewriteRule .* index.php [F]

RewriteBase /

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/index\.php

RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php [L]

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.example.com [NC]
RewriteRule (.*) http://example.com/ [R=301,L] 

如果我没理解错的话,把这一行放在 RewriteEngine 之后

RewriteRule ^gulf-job-listing/jobs/items/view/ /gulf-job-listing [L,R]