Rajesh
Rajesh

Reputation: 29

.htaccess file unable to redirect

I have a website which has many pages.

When I search my web my domain name, other pages

career.html contactus.html

are also shown in the result (as they are crawled).

Lets say i have career.html page and when i click on this in the searched results instead

of my career page i want the user to be redirected ti my index page.

For this i have an .htaccess file. It has the following code

#htaccess 
Redirect ^careers.html http://www.mydomainname.com/

This is what i have read online, that will take the user to my home page. But this is not working for me.

What else needs to be done to redirect the user to homepage. Thanks.

Upvotes: 0

Views: 66

Answers (2)

anubhava
anubhava

Reputation: 785246

You're using Redirect directive that doesn't accept regex. You can use it look this:

Redirect /careers.html /

Or else you can use RedirectMatch with regex support:

RedirectMatch "/careers\.html$ /

Upvotes: 0

Arthur Halma
Arthur Halma

Reputation: 4001

Try:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^careers.html$ /index.php [L]
</IfModule>

Upvotes: 2

Related Questions