Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Page redirects in htaccess file to remove one of a few subdirectories in URL

Hello everyone

I'm trying to implement a generic rewrite rule but am running into some problems. For example, the old url is test.com/auditorium/events/details/happy-hour and the new one is test.com/events/details/happy-hour i.e. "/auditorium" is should be removed from the new url. There are a few posts about this, but nothing to create the redirect correctly.

This is what we currently have:
rewritecond %{request_uri} ^/auditorium/events/details/ [nc]
rewriterule ^(.*)$ http://www.test.com/events/details/$1 [r=301,nc]
From what I can tell, the server isn't even hitting the rewritecond properly because the old url is still showing in the address bar.

Not sure if this matters, but the site is in Joomla. Thank you!
1 Solution
Try this in your root .htaccess file

RewriteEngine On
RewriteBase /
RewriteRule ^auditorium(/events/details/.*)$   $1 [R=301,NC,L]

Open in new window

Remember to check that mod_rewrite is included in the Apache httpd.conf, and that you have an Option FollowSymLinks  in a Directory entry in the httpd.conf or .htaccess file, without these mod_rewrite will not be available to you.
LaBowskiAuthor Commented:
Thank you!

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now