Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to redirect URL using wildcard?

Posted on 2008-10-27
Medium Priority
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

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, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 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