Need help with my .htaccess file

Aty

Elite Member
Joined
Jan 27, 2011
Messages
7,631
Reaction score
5,300
---- THREAD CLOSED 02/19/2015 ----
So my .htaccess file currently looks like this and it is working fine.

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase / 
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Now I would like to redirect two 404 pages to the homepage for the link juice.

I tried like this below but for some reason I cannot access the homepage anymore.

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase / 
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Redirect 301 /index.htm http://www.example.com/
Redirect 301 /m http://www.example.com/

Anyone has a working code for my above described needs?
 
I guess addding

Code:
ErrorDocument 404 http://'yourhomepage'.com

will do the job.This will redirect the missing pages to your homepage.
 
  • Like
Reactions: Aty
Replace your .htaccess with this:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase / 
Redirect 301 /index.htm http://www.example.com/
Redirect 301 /m http://www.example.com/
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Your current code does not work because you have defined a redirect rule as [L], or Last rule. So further rules will not be processed if that rule is processed.. hope that helps :)
 
Last edited:
  • Like
Reactions: Aty
Still not working.

It's not a Wordpress website and I would like to redirect only two pages.
 
I got your message with the screenshot. Sorry it was a mistake on my end that created the "inifinite redirect error" :P

Try the following instead:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^index.htm$ / [L,R=301]
RewriteRule ^m$ /  [L,R=301]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Let me know if this works. :)

Still not working.

It's not a Wordpress website and I would like to redirect only two pages.
 
Last edited:
  • Like
Reactions: Aty
It's not a Wordpress website and I would like to redirect only two pages.

You may use the below method to redirect custom urls

To redirect index.htm to youhomepage.php

Code:
RedirectMatch 301 ^/index\.htm$ /'yourhomepage.php

Here it's using the regular expression,and is comparing against the URL given.In this case 'index.htm'.

You can use this for any number of pages.
 
Last edited:
  • Like
Reactions: Aty
I got your message with the screenshot. Sorry it was a mistake on my end that created the "inifinite redirect error" :P

Try the following instead:

Code:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^index.htm$ / [L,R=301]
RewriteRule ^m$ /  [L,R=301]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Let me know if this works.
smile.png

This one works fine, thank you. :)
 
Back
Top