Solved

How to redirect URL using wildcard?

Posted on 2008-10-27
4
610 Views
Last Modified: 2012-05-05
Hello,

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

1) example.com/discussions/discussions/bla-bla
2) example.com/discussions/bla-bla

In essence removing the second "discussions" directory.

How would I achieve this in .htaccess?

Thanks,
Alex
0
Comment
Question by:cwdo
[X]
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
4 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 22816687
e.g. with
Redirect 301 /discussions/discussions/ http://www.example.com/discussions/

Open in new window

0
 

Author Comment

by:cwdo
ID: 22816749
Thanks for the quick reply.

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

http://www.example.com/discussions/bla-bla?q=discussions/discussions/bla-bla?

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

Accepted Solution

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

RewriteRule ^discussions/discussions/(.*)$ http://www.example.com/discussions/$1 [R=301,L]
0
 
LVL 27

Expert Comment

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

Add

RewriteRule ^discussions/(discussions/.*) http://www.example.com/$1 [R=301,L]

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

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

739 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