Jump to content

[SOLVED] Full path within ReWriteRule


trq

Recommended Posts

I'm basically looking to direct any requests to my front controller which is stored outside of my webroot. The full path is /home/thorpe/mymvc/core/init.php. Iv'e tried using...

 

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /home/thorpe/mymvc/core/init.php/$1 [L]
</IfModule>

 

However I'm getting permissions errors because I don't have any index.php within my web root and directory browsing permissions are disabled. However, given my rule I shouldn't need anything in my web root accept my .htaccess file. However, of course, the rule seems to be looking for /home/thorpe/mymvc/core/init.php somehow relative to my web root.

 

Any ideas?

Link to comment
Share on other sites

OK... Ive decided on a different approuch now. Ive made a symlink in my web root pointing to my mymvc framework. My .htaccess now looks like...

 

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ mymvc/core/init.php/$1 [L]
</IfModule>

 

This particially works. If I go to http://localhost or http://localhost/ I get the same permissions error about not having permissions to access / (rememeber, I have no directory browsing enabled).

 

However, if I access via http://localhost/anythingatallhere my request is sent through to my front controller.

 

How do I go about getting all requests to http://localhost to be sent aswell?

Link to comment
Share on other sites

A simple solution in case anyone else needs it. I simply added the DirectoryIndex directive.

 

My complete .htaccess file now looks like....

 

DirectoryIndex mymvc/core/init.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ mymvc/core/init.php/$1 [L]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.