Search code examples
.htaccessrootfile-rename

Renaming index.php in root directory


I have two applications on my root directory and im trying to keep them both there but they both have index.php files as a directory index. Is there a way to rename or change one of them so they dont overlap. Or have them both coexist together.

These are the apps im trying to keep under the same directory.

app # 1 https://github.com/wolfcms/wolfcms

app # 2 http://opencart.googlecode.com/svn/trunk/upload/


Solution

  • You can't without modification to both applications. Why not?

    Both application use htaccess rewrite to map a request to, say,

    GET /thisPath/SomeFutherContext
    

    to execute DOCROOT/thisPath/.htaccess which rewrites the request to do an internal redirect to DOCROOT/thisPath/index.php which then acts as a central clearing house to process SomeFutherContext.

    For the two to sit in the same thispath, you would need to integrate their .htaccess files, have two clearing house entries, say indexwolf.php and indexshop.php, and be able in the .htaccess through some regexp to decode SomeFutherContext so that you can dispatch to the right one.

    However, setting them up so that one is based on http://yourdomain/wolfcms/ and the other on http://yourdomain/shop/ is trivial, just follow the install guide for both and install opencart in DOCROOT/thisPath/shop/ changing RewriteBase in its .htaccess file to RewriteBase /shop/ as it instructs.

    BTW,

    1. If you are running on a shared service the php_flag directive won't work. You will need to configure your own php.ini
    2. Someone should tell the WolfCMS developers that location headers should conform to RFC 1945 ;-)

    Addendum

    If your hosting provider supports a wildcard subdomain mapper (most do by default, so either check your HSPs FAQs or post back here who your hosting provider is), then you can use subdomain e.g. wolfcms.yourdomain to separate it from your shop, by adding the following to your docroot .htaccess immediately after the RewriteBase /:

    RewriteCond %{HTTP_HOST} =wolfcms.yourdomain
    RewriteRule ^.*          wolf/$0              [L]
    

    You then store WolfCMS in Docroot/wolf, and its .htaccess is in DOCROOT/wolf/.htaccess with a RewriteBase / (not RewriteBase /wolf).