Jump to content
xisto Community
peroim

Directing All Urls In A Direcrory To One (Something like a 404 page)

Recommended Posts

I'm not sure what you really want to achieve, but here are few examples.

 

You can use META refresh tag to redirect a file to another location/file

<meta http-equiv="refresh" content="2;url=http://website">

where "2" represents the time in seconds and "url" is the location you want to send. This is a good method to direct a file that is no longer existing to keep your search engine from dropping you.

 

You can use HEADER tag in PHP

<?phpheader("Location: example.com/;; /* Redirect browser *//* Make sure that code below does not get executed when we redirect. */exit;?>
This is better way to deal with redirecting traffic since you can tell this script to point to 404 error message
<?phpheader("HTTP/1.0 404 Not Found");?>

Creating your own customized 404 and 403 error message would be the best way since any missing file/directory can be redirected to the location of your choosing by suing any of the examples above as your 404/403 page.

 

A suggestion would be that if you had domain1.org/folder1 that needs to be redirected to domain1.org/folder2 or domain1.org/file.html etc, make an index file with either of two codes above and place it under domain1.org/folder1/index so that any traffic that goes to folder1 would be redirected. If you want to redirect any missing file or folder to one location, use custom 404/403 error page and modify your .htaccess

Share this post


Link to post
Share on other sites

Thanks Buffalo & Electriic.Buffalo, your code codes are v?ry usefull if you want to redirect one page to another, but I need Electriic's solution, because I want to redirect every possible filename to another page.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.