FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


MVC problem





rohan2kool
I am trying to make an MVC structure like, if a person reaches the page:

Code:

http://localhost/index.php/mycontroller


I want the 'index.php' to be run, which then using the $_SERVER variables will load the required controller. The problem is that when I try to reach any page like that, I get the following message displayed:

Code:

No input file specified.


is there a workaround to this?
kv
Yes use mod rewrite (apache module -- in .htaccess file) to automatically internally convert your url

Code:

http://localhost/index.php/mycontroller


to something like this

Code:

http://localhost/index.php?controller=mycontroller


then in your index.php, mycontroller can be accessed by

Code:

$controller=$_GET['controller'];
rvec
Code:
RewriteEngine on
RewriteRule ^([.]*)/([.]*)$ index.php?controller=$1&view=$2

now you can send a user to http://localhost/controller/view and they will be redirected to http://localhost/index.php?controller=controller&view=view

You can leave view out, but I just added it to demonstrate how to add another one.
([.]*) means 0 or more characters of any kind except new line.
^ means start of a string and $ is the end

I think you should be able to modify it now.
rohan2kool
ahhh.. now i remember.. CI uses addresses like:

Code:

http://localhost/mypage/index.php?/mycontroller


I forgot the '?' part.. thanks a lot guys Very Happy

I can use .htacess then to change:

Code:

http://localhost/mypage/mycontroller


to:

Code:

http://localhost/mypage/index.php?/mycontroller


thanks a lot..
rvec
http://localhost/mypage/index.php?/mycontroller won't work you need http://localhost/mypage/index.php?mycontroller=....

but please read the post I made above here for the answer before rephrasing your question again.
Related topics
Problem with Subdomains
Strange Fire fox problem
Logout problem (Cookie?)
How to solve this problem? Thanks
I have a problem....Mozilla Firefox
post nuke problem
anyone had this phpBB problem?
phpbb problem....
Transport yourself over the Net
Problem with my password
Pictures problem...
database problem
same problem over here...
Header("Location: PROBLEM");
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.