简体   繁体   中英

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

I had to re-design a Joomla Listing site and the website used a component to show the listings. The url of the each item is as follows

example.com/gulf-job-listing/jobs/items/view/xxxxx

The xxxx is usually a combination of id and alias, so it might be something like this

example.com/gulf-job-listing/jobs/items/view/1-programmer

Anyways, what i'm trying to do is, to redirect all urls that are example.com/gulf-job-listing/jobs/items/view/xxxxx to example.com/gulf-job-listing

I tried to use the Joomla core redirect but i was only able to redirect only one url to another. ie i redirected example.com/gulf-job-listing/jobs/items/view/ to example.com/gulf-job-listing

my .htaccess file is as follows

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/$1 [R=301,L] 

如果我理解正确,请将此行紧接在RewriteEngine之后

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM