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

[eluser]spedax[/eluser]
I renamed my index.php to mynewindex

then I created a .htaccess file and placed it in the same folder

and I put this code in it.

Code:
<Files mynewindex>
AcceptPathInfo on
SetOutputFilter PHP
SetInputFilter PHP
</Files>

I found this is somewhere on the internet, but have no clue why it isen't working.

Any help is greatly appriciated.

edit : also tried nummerous other guides but nothing seems to work

i Set $config[‘index_page’] to an empty string

and my .htaccess looks like this

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #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]

    #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
    #This last condition enables access to the images and css folders, and the robots.txt file
    #Submitted by Michael Radlmaier (mradlmaier)
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    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>

My index.php is still called index.php.

anyone got any tips to get this to work ?

thanks
#2

[eluser]Pascal Kriete[/eluser]
So which one is it? Removing index.php or renaming it?
The first snippet you posted is renaming it, the second is completely removing it.

For renaming it, you could give the other two approaches outlined here a shot. You can, in theory, do both. I would start with renaming though, so remove the rest of that htaccess while you're testing that.

Let me know if that helps at all.
#3

[eluser]spedax[/eluser]
Well I actually just want the .php gone, so renaming would be my best option ?

and yes I tried the second part. This is the guide I followed http://codeigniter.com/wiki/mod_rewrite/

I'm so confused atm , I regret even trying Tongue

you say you can also compleetly remove index.php , but how does it work then ?
index.php/helloworld just because /helloworld ?

thanks for the reply
#4

[eluser]Colin Williams[/eluser]
And, yeah, you renamed it. So all the references to "index.php" in those rewrite instructions need to be updated.

Also, I always advise you take the time to understand how mod_rewrite works. It is the number 1 problem raised on the forums because people just seem to cut and paste code that other people say works. Then they change their folder structure (or rename the front controller) and it breaks down and they don't know what to do. It's usually quite clear once you understand how mod_rewrite works.

Case in point, there is a rather useless line of code in that htaccess, submitted by Michael Radlmaier. The previous 2 RewriteCond essentially make that third one moot.
#5

[eluser]Pascal Kriete[/eluser]
Quote:but how does it work then ?
Take a look at the url to this thread. It all goes through one file, the servers is simply hiding it.

These are two completely separate approaches. One is making your server parse a file as php, when the extension isn't ".php". The other is a server trick that tells it to take all requests that follow a specific pattern and toss them to the index.php file anyways. The latter is a lot harder to pull off consistently, because some hosts have very stringent rules about what you can and cannot do.

The following code block includes two example .htaccess files seperated by the OR line. You should only use one of the two techniques:
Code:
# The index file will be renamed, so
# it needs to be served properly
# if the homepage is viewed
DirectoryIndex index.php index.html myindex

# Make that renamed file run
# as php.
<Files myindex>
    ForceType application/x-httpd-php
</Files>

# ---- OR ----

# Rewrite urls
<IfModule mod_rewrite.c>
    RewriteEngine On

    # If the request doesn't start with any of the below
    RewriteCond $1 !^(images|static|index\.php|favicon\.ico|robots\.txt) [NC]

    # Prepend index.php internally
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

The comments do most of the work. The first is renaming the file. If you rename the file you will want to change the $config['index_page'] to the new name.
The second part is another solution to remove the file. If you want to remove the file, the name stays index.php, but the $config['index_page'] will be blank.

CodeIgniter uses that config item when it creates it own urls, hence the settings. Hope that helps at all. I know url rewriting is confusing at first, but renaming shouldn't be too difficult to grasp.
#6

[eluser]spedax[/eluser]
ah oke thanks both for the great info ! gives me some new stuff to try out Smile

Really appriciate putting some time in it.
#7

[eluser]spedax[/eluser]
oke I tried

Code:
# The index file will be renamed, so
# it needs to be served properly
# if the homepage is viewed
DirectoryIndex index.php index.html index

# Make that renamed file run
# as php.
<Files index>
    ForceType application/x-httpd-php
</Files>

renamed my index.php to index

changed the config['index_page'] to index instead of blank

Now it promps me to download application/x-httpd-php when I refresh the page 0.o




Theme © iAndrew 2016 - Forum software by © MyBB