0

I had a site, say example.com/drupal running on xampp

I have since changed the DocumentRoot in httpd.conf to /drupal/, so that I could access my site using example.com

But Google has already crawled my site and shows results of the form

example.com/drupal/something

which of course go to 404 pages.

How do I use RewriteRules to redirect

example.com/drupal/something

to

example.com/something ?

user160548
  • 25
  • 1
  • 3

2 Answers2

1

I'd simply use the standard Apache RedirectPermanent directive instead of bothering with attempting to use the relatively expensive Rewrite engine.

Check out http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectpermanent

mdpc
  • 11,856
  • 28
  • 53
  • 67
  • Thanks for your answer. It led me to http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch (RedirectMatch), and I used the rule like RedirectMatch 301 ^/drupal/(.*)$ http://www.example.com/$1 – user160548 Feb 18 '13 at 18:27
  • Yes, I was thinking about referencing that directive too. – mdpc Feb 18 '13 at 18:28
1
RewriteRule ^/drupal$ /
RewriteRule ^/drupal/(.*) /$1
Hauke Laging
  • 5,285
  • 2
  • 24
  • 40