Welcome Guest, Not a member yet? Register   Sign In
problem with index.php
#1

[eluser]franklyn[/eluser]
Hello! I would appreciate it if someone would help me with this problem.
When I go to my page http://127.0.0.1/testapp/ it works fine my default controller
serves the correct function, all good so far,
but when I test a new function for example http://127.0.0.1/testapp/newfunc,
it does not work, I have to write http:/ / 127.0.0.1/testapp/index.php/testfunc. What is the solution to this?
#2

[eluser]Sarfaraz Momin[/eluser]
It requires you to have an .htaccess file with rules to remove the index.php from the url. An example .htaccess which works for me is as follow:
Code:
Options +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Have a good day !!!
#3

[eluser]franklyn[/eluser]
Thank you for your fast response! I have tested with. .htacces file as you suggested, but it still not work properly. index.php must be in the url string in order to find the right class and function. http://localhost/lab/ is the look of the url when i surf to the page, put a test link my default class that links to function tester, results url is then when you click on the http://localhost/lab/tester and the does not work without manually add index.php as in http://localhost/lab/index.php/tester, is there something else I missed?
Code:
<?php

class Tester extends Controller {
    
    function index()
    {
        echo "<a >jklj";
        echo "</a>";
    }
}

?&gt;
#4

[eluser]Sarfaraz Momin[/eluser]
I am sure you have mod rewrite enabled on your hosting. If it is shared 99% it has to be enabled.
What I gave was an example of .htaccess file. The .htaccess which would suit your environment would depend on it. Please get me the details of your hosting and I would try out a right one for it. In the mean time you can also test the following .htaccess
Code:
Options +FollowSymLinks
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lab/index.php/$1 [L]
#5

[eluser]franklyn[/eluser]
Apache Environment
Variable Value
HTTP_ACCEPT */*
HTTP_ACCEPT_LANGUAGE sv
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0; GoogleT5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Diino 11.0.2804.9245 Debug; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506; .NET CLR 3.5.21022; Zune 3.0; Tablet PC 2.0)
HTTP_UA_CPU x86
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_HOST localhost
HTTP_CONNECTION Keep-Alive
HTTP_COOKIE PHPSESSID=qvktd8bv25ml9h5mukf5rmu0h4
PATH C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\QuickTime\QTSystem\
SystemRoot C:\Windows
COMSPEC C:\Windows\system32\cmd.exe
PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
WINDIR C:\Windows
SERVER_SIGNATURE no value
SERVER_SOFTWARE Apache/2.2.11 (Win32) PHP/5.2.8
SERVER_NAME localhost
SERVER_ADDR 127.0.0.1
SERVER_PORT 80
REMOTE_ADDR 127.0.0.1
DOCUMENT_ROOT C:/wamp/www/
SERVER_ADMIN admin@localhost
SCRIPT_FILENAME C:/wamp/www/lab/index.php
REMOTE_PORT 51467
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /lab/
SCRIPT_NAME /lab/index.php


Would this information be of any use for you?
#6

[eluser]Sarfaraz Momin[/eluser]
Are you using WAMP on windows. Please verify if mod rewrite is enabled. You can find it on phpinfo.
#7

[eluser]franklyn[/eluser]
It works now! Thank you so much, i had easyphp at first and then i switched to wamp and i moved the .htaccess file to the lab-folder, maybe that did the trick. Best Frank
#8

[eluser]Sarfaraz Momin[/eluser]
Good to know that. Good luck with your application.

Have a good day !!!




Theme © iAndrew 2016 - Forum software by © MyBB