CodeIgniter Forums

Full Version: mod rewrite - removing index.php from the URL help please
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]kdawson[/eluser]
Hi all, any help with this would be greatly appreciated:

I have a website where I have my CodeIgniter application i.e.
:

mywebsiteaddress.com/myapplication/index.php

my page URL's are looking like this :

mywebsiteaddress.com/myapplication/index.php/login/signup/

So I follow the instructions here >>> http://codeigniter.com/wiki/mod_rewrite/
to "take away “index.php” from your CI application URLs"

I have followed the instructions to the letter

My URLS's now look like this:
mywebsiteaddress.com/myapplication/login/signup/
But I get a "404 Not Found The server can not find the requested page"


Any way to narrow down what might be wrong?

Is there a httaccess file I can use to prove or show that my rewrite engine is indeed on and that is not the issue?


----

Come to think of it, I have an even bigger question -
Is there a way I can just call the whole library and functions in to any php page???

Even though it is late and I'm sure I'm sounding like a moron right now, I'm sure you know what I mean. How do I just get it all working in lets say ... mywebsiteaddress.com/Any_Page_I_Want.php ???
Why can't I just do that? Is that even possible to call all of the classes and everything in to there without that being my default_controller ???

And then I can just call it all again into a file mywebsiteaddress.com/WhateverDirectory/Any_Page_I_Want.php ???

I understand the whole DMV and how that works with the URL, but if your left jumping through hoops to get the URLS to look like what you want and have a directory structure that you want... then the framework seems like a bigger hassle than it was worth.


It is late and I am really tiered, (sorry if it sounds like a rant) but maybe someone can put me on to a way to simply call these classes and helpers and whatnot into any page that I want.


Thanks very much.

Regards



Thank you.
Regards

El Forum

El Forum

[eluser]XMadMax[/eluser]
Try this basic example:

.htaccess:
Code:
<IfModule mod_rewrite.c>
    # Turn on URL rewriting
    RewriteEngine On

    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Allow execution of any php files directly
    RewriteCond $1 !\.php$
    # Redirect any other url to index.php
    RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

Also, remove 'index.php' from the config.php file as: "$config['base_url'] = '';

El Forum

[eluser]kdawson[/eluser]
Hi Summer Student. Thanks but still the same.

I did exactly what you have above and the "index.php" is gone, but still the error:.
"
404 Not Found
The server can not find the requested page:
"

How do know the rewrite rule works?
Is there a simple .httaccess that proves if it is on and working... thereby eliminating one possible problem?

El Forum

[eluser]ηυмвєяσηє[/eluser]
it is possible to mod_rewrite is not active. Check your apache settings.

You can check it with running :

&lt;?php phpinfo(); ?&gt;
search for mod_rewrite, it should be in the 'Loaded Modules'.

El Forum

[eluser]kdawson[/eluser]
Hi Grad Student,

Is see this:

Loaded Modules core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_include mod_filter mod_log_config mod_logio mod_env mod_expires mod_headers mod_setenvif mod_version mod_proxy mod_proxy_connect mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_ajp mod_proxy_balancer mod_ssl prefork http_core mod_mime mod_status mod_autoindex mod_asis mod_info mod_suexec mod_cgi mod_negotiation mod_dir mod_actions mod_userdir mod_alias mod_rewrite mod_so mod_auth_passthrough mod_bwlimited mod_fpcgid mod_php5

and "mod_rewrite" is there like 6th from the last.

El Forum

[eluser]ηυмвєяσηє[/eluser]
Ok. If so, your .htaccess file is not for your folder structure.

Can you try this.

Code:
<ifmodule mod_rewrite.c="">
RewriteEngine On
RewriteBase /myapplication/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</ifmodule>
<ifmodule !mod_rewrite.c="">
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</ifmodule>

El Forum

[eluser]kdawson[/eluser]
Hi, Thank you but that did not work either.

It just throws a 404 not found...

Not sure what else I can do. I'm sure I have followed all of your instructions without making a mistake.

El Forum

[eluser]ηυмвєяσηє[/eluser]
i dont know about your folder structure.

If your site is placed in subfolder specify the path in the “RewriteBase /subfolder/” line.


“RewriteBase /myapplication/”

for mywebsiteaddress.com/myapplication/index.php/login/signup/

i think you have different folder name. u must change it.

El Forum

[eluser]kdawson[/eluser]
My folder structure is like this:

http://websitedomain/~Project_Folder/index.php/login/signup/


in /~Project_Folder/ I have the CodeIgniter folders:

/application/
/system/
/user_guide/

and in /~Project_Folder/ is where I have been applying the .htaccess rules.
Pages: 1 2