showing 404 page on mapped page
4 posts
• Page 1 of 1
- jobyvjohn2000
- Posts: 1
- Joined: 26 Oct 2012, 10:06
showing 404 page on mapped page
we are using map file to dynamically show our product display. if user type a wrong url, which is not included in map file, we want the page to be redirected to 404. Currently it is showing an error "Input string was not in a correct format.". you can check the attached image.
our product map file is as follows.
ProductA 33
ProductB 32
ProductC 31
ProductD 30
ProductE 29
We are using following rewrite rules in our .htaccess file.
RewriteEngine on
RewriteMap ProductMapFile txt:MapFiles/ProductMapFile.txt [NC]
RewriteRule ^product/([^./]+)([/]*)$ displayproduct.aspx?pid=${ProductMapFile:$1} [NC,L]
It will be very helpful if somebody can provide a point to overcome this bug.
Regards,
Joby
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: showing 404 page on mapped page
Hey,
I think we can solve it:
You can basically replace 404 with any non-existing page to generate 404 status... or you may create customized 404. ISAPI_Rewrite doesn't have flag to generate 404.
Regards
Andrew
I think we can solve it:
- Code: Select all
RewriteEngine on
RewriteMap ProductMapFile txt:MapFiles/ProductMapFile.txt [NC]
# if the entry is not in the mapfile, ignore the rule
RewriteCond ${mapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^product/([^./]+)([/]*)$ displayproduct.aspx?pid=${ProductMapFile:$1} [NC,L]
# if the entry is missiong, redirect somewhere else
RewriteCond ${mapfile:$1|NOT_FOUND} NOT_FOUND
RewriteRule ^product/([^./]+)([/]*)$ /404 [NC,R=301,L]
You can basically replace 404 with any non-existing page to generate 404 status... or you may create customized 404. ISAPI_Rewrite doesn't have flag to generate 404.
Regards
Andrew
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: showing 404 page on mapped page
It is customized page, but it will return 301 redirect. In case you want ErrorDocument, you need to use Ape.
Regards
Andrew
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests