Solved

How to redirect URL using wildcard?

Posted on 2008-10-27
4
608 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
  • 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
PHP Curl Multi-exec 13 72
Navicat software trying to restore Mysql backup Connection lost 23 125
PHP Error Settings 12 84
PHP in Apache server 20 102
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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