[solved]change 404 to 200

Alles, was den Apache betrifft, kann hier besprochen werden.

[solved]change 404 to 200

Postby svhorsch » 12. November 2011 19:38

Hey,

i tryed a lot, but i didn't found anyone else, who tried the same thing.

What i would like to change:
my idea is to change the 404 message, but not in the normal way, my apache should return the "index.php" file, he shouldn't send the 404 code, but the 200 code, so i can build a totally dynamic site, where all subpages are created with php and a big database.

example:

my directory
/test:
index.php
database_con.php

and now if i request the images.php page, the webserver should send the 200 code, with the url http:(....)/images.php but the file he should return, is the index.php camouflaged as the "images.php"

i hope you understood my idea / problem =)

in this moment:

my directory:
/test:
index.php
images.php
....
....
....


but in the images.php (and all the pages listed as "...") files there ist only this php-Code:"<?php include_once("index.php"); ?>"
it's working fine, but it is not exactly what i wanted to make.
User avatar
svhorsch
 
Posts: 3
Joined: 12. November 2011 19:10
Operating System: Windows 7/64bit

Re: change 404 to 200

Postby Altrea » 12. November 2011 19:49

Do you want to rewrite ALL requests (like a Frontcontroller pattern) or just the files which cannot be found?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: change 404 to 200

Postby svhorsch » 12. November 2011 19:52

all of them
User avatar
svhorsch
 
Posts: 3
Joined: 12. November 2011 19:10
Operating System: Windows 7/64bit

Re: change 404 to 200

Postby Altrea » 12. November 2011 20:30

I'm no mod_rewrite pro, but something like that should work

Code: Select all
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php [NC,L]

(stolen from an old Zend Framework Manual)

All requests exept .js, .ico, .gif, .jpg, .png and .css files will be rewritten to index.php
You can simply add or remove file extensions to the list.

You have to exclude static files otherwise your css or images in html code will not work anymore.

Maybe Nobbie the rewrite expert (to not say rewrite guru) does have a better idea.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: change 404 to 200

Postby svhorsch » 13. November 2011 16:40

hey altrea,

thank you for your fast and great answer. this is exactly what i wanted to make, my problem was that i always tried to change the 404 code =)

big thanks, now i can start with my totaly dynamic CMS
User avatar
svhorsch
 
Posts: 3
Joined: 12. November 2011 19:10
Operating System: Windows 7/64bit

Re: change 404 to 200

Postby Altrea » 13. November 2011 16:49

You're welcome :D

i will close this thread and mark it as solved.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to Apache

Who is online

Users browsing this forum: No registered users and 21 guests