Page 1 of 2

Solved: Rename index.php

Posted: Sat Feb 25, 2012 12:07 am
by dony_b
Is it possible to rename index.php or move it to a another folder so that its not on the root directory ?

For example change it to oc-index.php

or move it to a new folder /config/index.php

Re: Rename index.php

Posted: Sat Feb 25, 2012 12:33 am
by i2Paq
Search results for: rename index.php.

Re: Rename index.php

Posted: Sat Feb 25, 2012 12:38 am
by dony_b
For your info I always search the forum before I post anything...ive used OC long enough to know that. So thanks for showing me how to use google and not contribute to this support forum.

Re: Rename index.php

Posted: Sat Feb 25, 2012 12:42 am
by i2Paq
dony_b wrote:For your info I always search the forum before I post anything...ive used OC long enough to know that. So thanks for showing me how to use google and not contribute to this support forum.
And have you actually read any of the search results and what answer did you find that did not tell you what you probably found out yourself by trying to rename the index.php?
Did you even tried that, and did you try to move it to another folder?

What was the outcome of your reading and trying?

Re: Rename index.php

Posted: Sat Feb 25, 2012 12:47 am
by dony_b
Of course I tried renaming it and moving to a new folder and it does not work. I figured someone here might have done this already.

Re: Rename index.php

Posted: Sat Feb 25, 2012 12:50 am
by i2Paq
Next time you should mention that you have searched, what you have tried and if it failed (or not).

The more info you give, the greater the chance is that you get a to-the-point answer.

As far as I have tried and heard you cannot do what you want to do without a lot of coding (if you even will succeed).

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:06 am
by dony_b
It would have been easier if you had told me this form the start instead of trying to give me a lesson in how to use the forum....wasting both of our time

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:11 am
by JAY6390
It's possible to move/rename sure, but to what end do you want to do so?

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:18 am
by dony_b
JAY6390 wrote:It's possible to move/rename sure, but to what end do you want to do so?
I have another application in the root directory that has index.php so im trying to either rename the one one from OC or move to another folder. Do I need to change all occurrences where index.php is being if I was to change or move it.

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:21 am
by JAY6390
If you're on 1.5.X then this should be less of a problem. You can use the url class to make the right urls, and just change the index.php file to a new name. You would also need to amend the rule in .htaccess

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:24 am
by dony_b
Yes its 1.5.X

Do I need to change any other occurrences in the library or config ? Or just add the url class and change it in the htaccess

Re: Rename index.php

Posted: Sat Feb 25, 2012 1:32 am
by JAY6390
config shouldn't be an issue. I've just done a grep, and there are actually 97 instances over 37 files on my local copy (15131). The problem is the url class is only used for certain areas, where as it should be done throughout the cart. if you have a good search replace tool like grepwin you could do it in no time. Be careful not to rename the admin index.php instance, there are far more in that folder, and of course you shouldn't need to edit that index file

Re: Rename index.php

Posted: Sat Feb 25, 2012 3:25 am
by Qphoria
Try this....

(1.5.x ONLY)

1. rename index.php to ocindex.php

2. Edit .htaccess and add to the top:

Code: Select all

DirectoryIndex ocindex.php
3. Global Replace "index.php" with "ocindex.php" in the opencart "catalog" and "system" folders only, filtering on php and tpl files.

You will likely have to do this locally unless you know how to do it with linux SSH.
If you do it locally, change the files and reupload them over your existing files. There are 35 files in the catalog folder and 1 file in the system folder.

Re: Rename index.php

Posted: Sat Feb 25, 2012 3:32 am
by JAY6390
It stands to reason that if the url class is rewritten to use ocindex.php, then all of the admin files will need to be rewritten too, as it uses the url class

Re: Rename index.php

Posted: Sat Feb 25, 2012 4:56 am
by Qphoria
JAY6390 wrote:It stands to reason that if the url class is rewritten to use ocindex.php, then all of the admin files will need to be rewritten too, as it uses the url class
that does stand to reason. I never tested it.. just saying to try it. In which case then run the global replace across the WHOLE thing.

Re: Rename index.php

Posted: Sat Feb 25, 2012 5:55 am
by JAY6390
Yeah. Renaming both index.php files to ocindex.php, then replace all index.php text across all OC files

On a clean 1505 (old yes I know) I get 253 matches over 86 files...so there's quite a few bits to change, but it is possible to do definitely

Re: Rename index.php

Posted: Sat Feb 25, 2012 10:49 am
by dony_b
Qphoria wrote:Try this....

(1.5.x ONLY)

1. rename index.php to ocindex.php

2. Edit .htaccess and add to the top:

Code: Select all

DirectoryIndex ocindex.php
3. Global Replace "index.php" with "ocindex.php" in the opencart "catalog" and "system" folders only, filtering on php and tpl files.

You will likely have to do this locally unless you know how to do it with linux SSH.
If you do it locally, change the files and reupload them over your existing files. There are 35 files in the catalog folder and 1 file in the system folder.
I wonder if this is going to affect other mods or vqmod files ?

Re: Rename index.php

Posted: Sat Feb 25, 2012 2:42 pm
by Renato Frota
I'm wondering why you need 2 applications running in the same folder and also how renaming index.php to ocindex.php will make your other application usable if you need to set default index of the directory to ocindex.php anyway to achieve a functional opencart (because of the high number of urls generated without index.php - or renamed ocindex.php)?

You will still need to hardcode index.php in URL to your other system! Then it's definitelly easier to hardcode othersystemindex.php and leave opencart as is, as OpenCart will be the default for url.com/ (without filename) in any case!

Re: Rename index.php

Posted: Sun Feb 26, 2012 12:34 am
by dony_b
JAY6390 wrote:Yeah. Renaming both index.php files to ocindex.php, then replace all index.php text across all OC files

On a clean 1505 (old yes I know) I get 253 matches over 86 files...so there's quite a few bits to change, but it is possible to do definitely
It looks like a quite a few instances to change and might not be worth. Im thinking to create a wildcard subdomain to separate the two apps so I dont have to rename anything.

Lets say I create a subdomain test.domain.com and have the docroot /test/ then redirect it to the primary domain so I keep the same url structure the same.
Add this to .htaccess

Code: Select all

RewriteBase /
RewriteCond %{HTTP_HOST} =test.domain.com
RewriteRule ^.*   test/$0   [L]
will this work ?

Re: Rename index.php

Posted: Sun Feb 26, 2012 12:38 am
by JAY6390
Perhaps we're going about this the wrong way :)

Can you explain why you need both apps in the same folder please?