How to redirect URL using wildcard?

Posted on 2008-10-27
Last Modified: 2012-05-05

I'm trying to 301 redirect all pages from 1) to 2):


In essence removing the second "discussions" directory.

How would I achieve this in .htaccess?

Question by:cwdo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 27

Expert Comment

ID: 22816687
e.g. with
Redirect 301 /discussions/discussions/

Open in new window


Author Comment

ID: 22816749
Thanks for the quick reply.

I added your suggestion to .htaccess, but it doesn't quite work as intended.  It redirects to:

Note that this is on a Drupal site, so Drupal may be imposing some .htaccess restrictions?

Accepted Solution

cwdo earned 0 total points
ID: 22816885
Got it to work:

RewriteRule ^discussions/discussions/(.*)$$1 [R=301,L]
LVL 27

Expert Comment

ID: 22816918
It looks like that you're using mod_rewrite and it conflicts with one or some of your rules.


RewriteRule ^discussions/(discussions/.*)$1 [R=301,L]

below the line
'RewriteEngine on', i.e. above the RewriteRuls from drupal.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question