php application made using codeigniter framework links are not working - php

I set up a ubuntu server in a virtual pc. and I put my php application that was created using codeigniter framework to /var/www/sdbl folder.
now i can view the index page of my application. but all links are broken.
I put these codes in to .htaccess file and it is in /var/www/sdbl folder.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
the same application is working well on this link
http://3linksit.com/sdbl/
can some one give me some help with this issue?
Thanks in advance.

If i have got your question right you want to make your links working & remove 'index.php' from URL.Follow following steps & let me know if that solves your issue.
1) Remove 'index.php' from config.php which is located in config directory
make it look like this $config['index_page'] = '';
2) Add this to .htaccess file
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
If you have any doubts or issues let me know.Hope it helps.
Best Regards,
Zeeshan.

Related

Flight PHP Routing from Subdirectory

So I'm using the Flight PHP microframework (http://flightphp.com/) to do routing. My question is, how can I run the router from within a subdirectory? What I mean is, essentially, run it 'sandboxed' within a folder.
As in, a request to '/' just pulls the regular index.php file. But a request to '/flight/file' would load the URL using Flight.
I know you can't just dump it in a folder on the server and expect it to work because FlightPHP expects the URLs relative to the root.
Is there a way to run FlightPHP isolated in a directory with the rest of the website running regular PHP?
EDIT
I tried simply putting the .htaccess file into the subdirectory. This has the peculiar effect of causing the routes to still act as if they are from the root (e.g. /thing/otherthing/ when it should be /otherdirectory/thing/otherthing/ ) while simultaneously causing the 404 callback to not work. Not what I intended.
EDIT 2
Contents of .htaccess file, which are what is suggested by the Flightphp website:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
I know this is an old question but I've been doing something similar just by adding something along the lines of
RewriteBase /flight/
in the .htaccess file (before all of your rules) of the flight directory. Hope this helps someone else looking for the same thing. Example:
RewriteEngine On
RewriteBase /flight/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
Sorry for giving you an answer that is not going to help a lot. I'm running Flight (also sandboxing) on a subdirectory. I've created an .htaccess just with the defaults in the subdir and Flight is now regarding this as it's root.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
Did you check the content of the .htaccess on the higher levels, maybe there is something that is blocking you

shift folder in url via htaccess

imagine the following situation:
i've got a folder on the webserver:
www.domain.com/test/project
in "project", i've got my whole php application. in "project" i've also got the following .htaccess file:
RewriteEngine On
rewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(util/(css|js))($|/) - [L]
rewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(UI/designs)($|/) - [L]
RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]
which allows me basically to have url like this for example:
www.domain.com/test/project/admin/user
i've allowed access to "util/(css|js)" for loading the css and js files from ther
but eventually i want to have this url for example:
www.domain.com/test/admin/user
so basically, to just shift the "project" folder....
is this possible with an .htaccess file?
is this also possible with the following example:
www.domain.com/project/admin/user
www.domain.com/admin/user
please help me, i often tap into 500 internal server error :(
i tried something like this:
RewriteRule ^test/(.+)$ http://www.happydomain.org/folder/$1 #[R=301,L]
i've got the solution! =)
this .htaccess must be adden in the "test" folder - concerning my example mentioned in the question
RewriteEngine On
RewriteCond %{REQUEST_URI} !^project/
RewriteRule ^(.*)$ project/$1 [L]

codeigniter index.php file mod rewrite

Hi i am new to codeigniter and using this as my url
http://localhost/codeigniter/index.php/site
and have included following htaccess file
RewriteEngine On
RewriteBase/codeigniter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [PT,L]
after including this htaccess filr to codeigniter folder the web page stops working on both
http://localhost/codeigniter/index.php/site
and
http://localhost/codeigniter
basically i need
http://localhost/codeigniter
to work
please help
Thanks
You are missing a whitespace between your RewriteBase and the base URI:
RewriteBase /codeigniter
This is probably why things has stopped working (a server error status 500, which you could find in your error log).
Use this one,
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
For more details Click Here.
In order to have your codeigniter site default to the site controller you need to update config/routes.php to set the site controller as the default route.
For the rewrite issue see #Repox's answer.

CI not working locally

Instead of working live on my site I've decided to try and work locally and install new version later on my live site.
So I'm working with Codeigniter and have the following struture.
/htdocs/kow(site)/kowmanager(cms)
When I load https:localhost/kow it loads the correct controller however for some reason its not reconizing that kowmanager is a sub directory of kow with its own application folder and it should be loading the default controller that is set in its routes file. When I load https://localhost.com/kow/kowmanager it loads a page that says index of /kow/kowmanager and then a link to the parent directory. Which isn't anything CI related.
Inside the kow directory this is my .htaccess file. Is this the problem?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteEngine On
RewriteBase /kowmanager
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I'm using xxamp.
You need an index.php-page for each application as stated by the manual.
So I think you should copy your index.php to indexManager.php and in it change the application folder.
$application_folder = "kowmanager";
About the rewrite I am not sure but I think it is in line with:
RewriteEngine On
RewriteBase /kowmanager
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ indexManager.php?/$1 [L]
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
are you using a .htaccess to remove index.php from urls ?
is /htdocs/kow the base directory of your project where CI is installed ?
you need to put kowmanagers in the controllers directory, and specify which controller to call, I'm not sure CI supports calling default controllers from directories unless you specify it in the routes.php config file.
Anyway, please give further information if you want a precise answer.
What is in kowmanager and why do you have two rewrites? If your directory structure is how I assume it is, you might get away with just removing the second kowmanager directive from your .htaccess file.
Which folder is codeigniter in? All you want to do is rewrite the url to remove index.php, but unless you're mapping the url to codeigniter's index.php, it will never be able to load controllers.
Apache has a lot of info on url rewrite. Its a lot of reading and the behavior is always pretty finicky, but maybe it will help you:
Otherwise, more info will help us help you. P.S. I'd also tag this with apache, as that is where the problem is, and you're more likely to get people who know a lot about apache to view your question.

mod rewrite for url, Internal Server Error, Kind of works when I put ? after the url

I uploaded a project to a directory. I have a subdomain which points to this directory.
root/foo => foo.mydomain.com
When I go to foo.mydomain.com, I get the error "Internal Server Error", I'm sure this has to do with .htaccess, but I haven't got a clue where to go. Do I put the .htaccess in the root? or the folder which points to my subdomain.
So to Summarize:
I have a subdomain foo.mydomain.com, this points to a directory in my root (root/foo/index.php).
I need a .htaccess file which can resolve this error. My Current .htaccess file is here:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I know this .htaccess file is wrong, because it was what I used on my localhost, Where this project was in the root. Now I've taken it out the root, I need a working .htaccess to fix this. What do I need to edit in the above code to make my project work.
Project: root/foo/index.php <-- This is where my project is(directory called "foo")
I also have a subdomain pointing to ^^ The said directory.
Hey I too was having the same issue. Just now I fixed after trying a lot :D . Add RewriteBase :) .
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Hope it will work for you too.

Categories