Simple Machines Community Forum

General Community => Scripting Help => Topic started by: sikkens1997 on May 06, 2011, 07:00:03 AM

Title: Redirect to homepage if the page doesnt excist
Post by: sikkens1997 on May 06, 2011, 07:00:03 AM
Hello, I wanna know how to make a redirect link to another page, if my visitors go to a page that does not excist.

Example: I go to www.mydomain.com/birthday and this page does not excist. How will I make it so, that they get redirected to the link www.mydomain.com/pagenotfound

And so with all the pages that does not excist, that they get redirected to the link www.mydomain.com/pagenotfound


I know I must do this in .htacces but i don't know what to put in there.
Title: Re: Redirect to homepage if the page doesnt excist
Post by: gamesmad on May 06, 2011, 07:30:24 AM
Create a file called ".htaccess" in your root folder and paste "ErrorDocument 404 /404.html" into it.

This will redirect any missing pages to "404.html", or any other page you like.
Title: Re: Redirect to homepage if the page doesnt excist
Post by: sikkens1997 on May 06, 2011, 08:56:07 AM
Thanks :D
Title: Re: Redirect to homepage if the page doesnt excist
Post by: gamesmad on May 11, 2011, 10:36:16 AM
No worries, I will mark this one as solved :)
Title: Re: Redirect to homepage if the page doesnt excist
Post by: sikkens1997 on May 18, 2011, 09:34:06 AM
Not solved. :(
I could not try this, since I didn't have the domain yet. Now I do.
When I go to FTP, and I put the file in there, it's there. When I reconnect or go to the site, It's not in there.

EDIT: It's because it's a secured file. I got in the File Manager and there it was.
Now I edited it like you said, excactly that but it doesn't work. :(

FINAL EDIT: It was because the page did not excist. It works totally fine now. Thanks <3

SOLVED
Title: Re: Redirect to homepage if the page doesnt excist
Post by: NanoSector on May 18, 2011, 09:44:02 AM
Glad you got it solved! :)