Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Need wildcard mod_rewrite

    I need to direct all visitors that enter my /old top directory to be redirected to my home index page. This would include every single file in the old directory that's either bookmarked or linked by Google. Simple 301 redirects work very well, however I have a mass amount of files in this directory and I don't want to redirect each file. What I really need is a wildcard redirect that will simply link all files in this one directory to automatically send visitor to homepage.

    I have used cpanel for this initially, but I find that for a simple 301 redirect for one file the coding is too complex and ultimately doesn't work anyways. Even the wildcard setting does not work, so I have always felt comfortable doing my own mods and besides it's even better for SEO.

    I have experimented with many different mods that should work but don't such as:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    Redirect 301 /my_directory/ homepage URL
    RedirectMatch 301 /my_directory(.*) /$1

    RedirectMatch 301 ^/my_directory/(.*)$homepage URL/$1

    Now keep in mind I do have an .htaccess file in this top directory and there was a suggestion in another forum to place this mod in this file while doing a standard 301 redirect in the root directory:
    This does not work either.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^my_directory/(.*)$ /$1 [R=301,NC,L]

    There must be somebody in this community that has done this sucessfull wildcard redirect for a top directory.

  2. #2
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Western Kentucky
    have you looked here
    linux user # 503963

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts