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/di scussions/ bla-bla
2) example.com/discussions/bl a-bla
In essence removing the second "discussions" directory.
How would I achieve this in .htaccess?
Thanks,
Alex
I'm trying to 301 redirect all pages from 1) to 2):
1) example.com/discussions/di
2) example.com/discussions/bl
In essence removing the second "discussions" directory.
How would I achieve this in .htaccess?
Thanks,
Alex
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
Add
RewriteRule ^discussions/(discussions/
below the line
'RewriteEngine on', i.e. above the RewriteRuls from drupal.
Open in new window