I need to replicate an alias directive within a .htaccess file (on a shared host, don’t have access to my hosts apache conf).
The directive is as follows:
Alias "/" "/var/www/core/web/index.php/"
I’ve tried various configurations of mod rewrite, but it’s not doing what I want. I’m a fish out of water with some of the more specific apache stuff… hoping we’ve got someone here who can help.
This has got me part of the way there:
Options +FollowSymLinks
RewriteEngine On
DirectoryIndex index.php
#Set the base uri
RewriteBase /mysource_matrix
#Now do some rules for redirection
#if index, don't redirect (again)
RewriteRule index.php -
#don't redirect double-underscore dirs (symbolic links)
RewriteRule __lib -
RewriteRule __data -
RewriteRule __fudge -
#redirect everything else to index.php
RewriteRule (.*) index.php/$1 [L]
I get apache 500 internal server error when trying to use this - the problem is the last line - it’s supposed to write to a index.php symbolic link in the web root… but, it doesn’t. I’ve tried re-writing it directly to the file and that produces the same problem.
I think the problem was that you were not terminating the early statements with the Last flag so mod_rewrite kept truckin’ through the code until it hit the EVERYTHING atom and dumped it all (including index.php) in the “subdirectory” for index.php. (IMHO, CRAZY code :mad: and you’re lucky you didn’t take down your server! PLEASE learn the RARE occasions when (.*) is actually the correct code to use.)
Thanks for the advice I inherited this from elsewhere - lucky it hasn’t caused problems.
This is how my .htaccess file looks at the moment. It’s still throwing 500 internal server errors:
Options +FollowSymLinks
RewriteEngine On
DirectoryIndex index.php
#Set the base uri
RewriteBase /mysource_matrix
#don't redirect double-underscore dirs (symbolic links)
RewriteCond %{REQUEST_URI} !__
#redirect everything else to index.php
RewriteRule (.*) index.php/$1 [L]
Mod rewrite is on, I’m using it for other sites on the same server, double underscores are working fine, still having issues with that last bit.
Bear in mind, my alias’ work fine on a test box - it pushes everything through to the scripts landing page… the rewrite doesn’t. Are they supposed to behave in the same manner?
It’s got me past those internal server errors … I’m still kinda stuck at the beginning again - it’s not behaving the same as an alias directive. Not to worry though, at least it’s given me a place to start.
Added the extra slash, but still the same problem.
I get:
No input file specified.
I think this is being generated by apache, the code I’m using doesn’t (well shouldn’t) produce this flavour of error.
I tried to use acceptpathinfo, but get a 500 internal server error. I’m not 100% certain on the apache version so it’s either my implementation of the example, or my version. Have to check up on that.
That flag is great, I can see it re-directing to the correct page (I’ve tried both real path, and the path to the symbolic link I created).
RewriteRule !^/*(__|index\.php) index.php%{REQUEST_URI} [L] makes the extension for index.php/path/to/request.extension and that doesn’t make any sense at all! Perhaps a ? before the %{REQUEST_URI} might help?
that’s exactly the string that I want - the script interprets $_SERVER[‘PHP_SELF’], so that url is perfectly ok. It’s working like that in it’s current state (ie the URL), but it’s not running the appropriate php script.
I can’t find any doco on getting AcceptPathInfo working in apache 1.3.x unfortunately - anyone got any bright ideas?
I’ve added it, still no joy - terribly frustrating issue that could be solved by the host upgrading apache, but I don’t think I’ll see that any time soon.
That Vhost conf works for 1.3. What you need to look at is how to handle PATH_INFO in Apache 1.3. What’s also important is whether your PHP is running as a CGI or as Apache module. If I remember correctly, if it’s CGI, you’re out of luck.
Btw if you’re really running MySource Matrix, forget a shared webhosting account. Think big fat dedicated server(s).