2

is a htaccess 301 redirect possible with this url?

www.example.com/en/job/viewcompany/company-x/nav-35

I want to redirect above url to the one below, eliminating 'nav-35' from it

www.example.com/en/job/viewcompany/company-x

NOTE: Company-x can be any company name. Depends on which that has been fetched from the DB

Found this example but wasn't applicable in my case: How can I use htaccess to redirect paths with a wildcard character

Sorry. Forgot to mention that

www.example.com/en/job/viewcompany/company-x/nav-35

is also a redirect from

www.example.com/en/job/viewcompany/cat-x/company-x/nav-35

as below

Redirect 301 /en/job/viewcompany/cat-x/  http://example.com/en/job/viewcompany/
Community
  • 1
  • 1
Vincent
  • 23
  • 3

1 Answers1

1

You can try this rule in root .htaccess:

RewriteEngine On

RewriteRule ^(.+)/nav-\d+/?$ /$1 [L,NC,R=302,NE]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Thanks. I've tried but didn't work. Could it be because the url is already a redirect? – Vincent Mar 18 '16 at 22:42
  • No, I think it indicates site language: English. it's a Joomla site. This is how the original url structure looked like /en/component/componentname/company/viewcompany/cat-x/company-x/nav-32 -- Removed 'component', 'componentname' and 'company' by redirecting to /en/job/viewcompany/cat-x/company-x/nav-32 -- then removed 'category number' by redirecting to /en/job/viewcompany/company-x/nav-32 Now I want to remove nav-32 from it. --Joomla CMS-- – Vincent Mar 19 '16 at 09:07
  • http://www.itandtelecomkenya.com/en/job/viewcompany/cat-57/company-farm-concern-international-fci-20/nav-35 and http://www.itandtelecomkenya.com/en/job/viewcompany/cat-57/company-farm-concern-international-fci-20/ all land on the same page. In google webmasters i'm getting duplicate description. Also both urls canonical. – Vincent Mar 19 '16 at 10:07
  • I want all urls with a nav- at the end to redirect to ones that do not. Like in the urls i've given above. I want the first one to be redirected to the second one – Vincent Mar 19 '16 at 11:02