Welcome Guest, Not a member yet? Register   Sign In
removing index.php (docs are kinda sucky for this)
#1

[eluser]codeamanny[/eluser]
I have been trying to follow the docs and have hit walls the whole way

In the docs it says
Quote:removing the index.php file

By default, the index.php file will be included in your URLs:
www.your-site.com/index.php/news/article/my_article

You can easily remove this file by using a .htaccess file with some simple rules. Here is an example of such a file, using the "negative" method in which everything is redirected except the specified items:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

In the above example, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.

But it doesn't say the following:

where you should put the .htaccess file ( I put it into my apps folder)
however everytime I post a form, the index.php comes back. I have tried to remove the index.php using the $config option, however all my forms then post to the correct url, however it just goes to 404 errors!

Can someone help?
however
#2

[eluser]xwero[/eluser]
If you put it where the index.php file is you will have no problems.
#3

[eluser]codeamanny[/eluser]
its stil not working,

If I put this into the url
http://virtual/project/company/project/b...ivepayment

it doesn't work however if i put in

http://virtual/project/company/project/b...ivepayment

it works.
#4

[eluser]codeamanny[/eluser]
It turns out htaccess doesn't work with the current version of windows we are using, so I have to just make do.

How do I reference images if I am calling them from a view?

eg controller http://virtual/project/company/project/b...ivepayment
loads viewpayment.php in the views folder
#5

[eluser]xwero[/eluser]
.htacces files are cascading. If you put the file in your root directory all subdirectories will have the same redirecting rules. if you put it in a sub directory with other redirection rules those rules are only valid for that subdirectory and all its subdirectories.

Here you can find a good introduction to .htaccess . It's not really in the reach of CI to explain mod_rewrite because there are other webservers than apache and they can have other ways of rewriting urls.
#6

[eluser]codeamanny[/eluser]
@xwero Thanks for the help, however my server doesn't support htaccess! I just worked it out.

How do I reference images from within my view?
#7

[eluser]ngkong[/eluser]
put the htaccess at directory http://virtual/project/company/project/branches/codign/

and the htaccess should be:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /project/company/project/branches/codign/index.php/$1 [L]

set line 3 as the path to your codeigniter index.php directory (from webserver root)

while you upload the script to remote server, change htaccess back to normal (if your script run at domain root)

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
#8

[eluser]Michael Ekoka[/eluser]
If your apache server's settings do not allow override, htaccess files will have no effect. You'll need to set the AllowOverride to All in the apache configuration file.
#9

[eluser]captainbeef[/eluser]
Hey,
The way I reference images is to keep the images in a folder under the site root folder.
Then when you reference the images in the view files, you just use a leading slash and the image folder name, thus:

Code:
<img src="/images/image1.gif">

When this is called in the browser, the image path is appended to the site domain. This then loads the image, independent of the framework paths.

This method can be used to store and reference any files that are to be made globally available and are called in html (i.e. at the client end of things), such as css, pdf's etc
#10

[eluser]jrad[/eluser]
Had the same problem with .htaccess file.. My solution was this:
1. Set your config.php file

$config['base_url'] = "http://127.0.0.1/path/of/codeigniter"; #if you use http://127.0.0.1/path/to/
codeigniter/ in your browser
$config['base_url'] = "http://localhost/path/of/codeigniter"; #if you use http://localhost/path/to/
codeigniter/ in your browser
if you placed codeigniter in the root folder set base_url to http://localhost/ or http://127.0.0.1/
$config['index_page'] = ''; #default is $config['index_page'] = "index.php";

2. Make the .htaccess file as mentioned above in your system folder.

3. Edit your Apache httpd.conf file

Option Indexes FollowSymLinks
AllowOverride All

4. Restart Apache.




Theme © iAndrew 2016 - Forum software by © MyBB