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.
Related
I'm dealing with a codeigniter app that I haven't developed and is not working , if I request the main url the main controller is not called(and every route I've tried gets an 404 error), the browser shows the directory listed.
Another project on the same server with codeigniter without any changes works correctly,
Anyone know what could be the problem??
Make sure you have added the project folder in the base_url like below
$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].'/project_folder/';
$config['index_page'] = '';
and, update your .htaccess file with this code
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I have wordpress installed and in the root i created a folder and put an .htaccess inside to redirect to another web page without changing the URL.
This was working fine until i move to another server (the older one was just horrible) and now it just not working.
This is code that i was using:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1 [R=301,L,P]
and is no longer working, show me this:
looking for internet i have tested some other codes:
1-
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^/conexionalam(/.*|)$ nuevoserver.breinguash.com$1 [L,NC]
2-
RewriteEngine ON
RewriteRule ^/(.+) http://nuevoserver.breinguash.com/$1 [R,L]
This two show me this:
3-
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1
This one redirect me to http://nuevoserver.breinguash.com/index.html
I realized that if i took off this '[R=301,L,P]' at the end of the first code, it works but changing the URL and i don't want tat.
Thanks in advanced!
EDIT:
By the moment im using this code:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1
Its redirects but change the URL = /
but for now does not affect google analytics.
if i change or add something to the code it does show me the errors from above. i really doesn't understand why it does that.
SOLUTION
Well it seem that i cant redirect between domains/subdomains without changing the URL just like that, i have to do it with proxy, so the solution was:
Enable proxy and proxy-http on apache.
Use the P flag for RewriteRule
So right now i'm using this code and it works perfectly:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/conexionalam
RewriteRule ^(.*)$ http://nuevoserver.breinguash.com/$1 [R=301,L,P]
Give this a shot in your .htaccess file...
RewriteEngine On
RewriteBase /
RewriteRule ^conexionalam(.*)$ http://nuevoserver.breinguash.com/$1 [L,R=301]
This should redirect you to http://nuevoserver.breinguash.com when you go to /conexionalam from your main domain.
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.
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]
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.