Link to home
Start Free TrialLog in
Avatar of cwdo
cwdo

asked on

How to redirect URL using wildcard?

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
Avatar of caterham_www
caterham_www
Flag of Germany image

e.g. with
Redirect 301 /discussions/discussions/ http://www.example.com/discussions/

Open in new window

Avatar of cwdo
cwdo

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of cwdo
cwdo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.