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
https://forums.phpfreaks.com/topic/59115-solved-full-path-within-rewriterule/
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?

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.