homepage Welcome to WebmasterWorld Guest from 54.235.16.159
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
404 redirect
404 redirect
gagankkharbanda




msg:4461705
 5:01 pm on Jun 5, 2012 (gmt 0)

Hi,

My URL is Example.com/gas.php?cid=1 and this URL is opening fine and now a URL which is Example.com/gas.php?cid=123(which actually doesnt exists) but this URL is able to open but a blank page (not even 404 error as gas.php exists) and I want to redirect this page and others where there is no information to main page i.e. Example.com/gas.php

Pls help

 

g1smd




msg:4461728
 6:09 pm on Jun 5, 2012 (gmt 0)

You do this in the PHP file not in htaccess.

The first part of your PHP script should examine the requested parameters and if they are completely invalid (e.g. ?cid=1h34f3) return a 404 status code and include the 404 page code and content.

The next part of the PHP code should examine plausible parameter values (e.g. ?cid=12345) and check in the database to see if this value exists. If it does not, return a 404 status code and include the 404 page code and content.

If the parameter value is OK and is found in the database then serve the content for that id.

Do NOT redirect non-valid values. Your site will be flagged as having "soft 404 errors". You do NOT want this.

If your code begins with the !DOCTYPE then you will have to refactor your code. The PHP script should interact with the database first and the !DOCTYPE should be at least half way through the script.

gagankkharbanda




msg:4462163
 7:42 pm on Jun 6, 2012 (gmt 0)

Thanks!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved