How to make a home page redirect

Hi,

We want people going to:

www.anooz.com/sarah

to be redirected to:

but of course we do not want someone going to:

www.anooz.com/about_us.php

to be redirected.

I have set up this .htaccess but it is not working:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^/(.*)$ aa_redirect.php?name=$1

What needs to be corrected in above code?
ThanX

Use .htaccess for any redirects

Sorry I didn’t read your comment properly. One not use cPanel inbuilt redirection. This will set the values correctly. If all else fails, delete the access file and rebuild it which will take care of any syntax errors, but then you lose any previous saves

1st, we do not use Cpanel.
2nd, this issue is something that should be strictly addressed by the .htaccess file. My only question is what I am doing wrong in the above code as a result of which redirect is failing?

FYI: the redirect works correctly when entered as a sub-dir of root, like:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^blog/(.*)$ aa_redirect.php?name=$1

but it is not working correctly for the root dir itself, which again is my Q as to why?

WN,

Have you read the sticky post OR the mod_rewrite tutorial linked in my signature (a better version of the sticky posts)? That would have answered the question for you.

[COLOR="#A9A9A9"]Options +FollowSymLinks[/COLOR]
RewriteEngine on
[COLOR="#FF0000"]RewriteBase /[/COLOR]
RewriteRule ^/(.*)$ aa_redirect.php?name=$1

That won’t work simply because it’s loopy code (and Apache 2 refuses/refused to match the leading /).

[standard rant #1][indent]The use of “lazy regex,” specifically the :kaioken: EVERYTHING :kaioken: atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/standard rant #1]

Okay, specification:

Your specification is insufficient as “sarah” is likely to be a variable. Above, you’ve constructed the variable with ONLY lowercase letters. This is easily differentiated from about_us.php by both the _ and the dot character. However, mod_rewrite provides a “safety value” in that it allows you to check whether the request was for a file which exists. Taking advantage of these “refinements,”

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f # to check on an existing file
RewriteCond %{REQUEST_FILENAME} !-d # to check on an existing directory
RewriteRule ^([a-z]+)$ aa_redirect.php?name=$1 [L]

If you’re not sure what version of Apache you’re using, replace the ^ (or your ^/) with ^/? as this will work with both Apache 1.x and Apache 2.x.

Regards,

DK