I am having a very strange issue using mod_rewrite under Leopard. Take the following example:
- In my ~/Sites folder, I have a folder called mysite_v1, which contains several PHP files and a .htaccess file with the following contents:
- All the files required by the rewrites exist in the same folder.
- When I visit http://localhost/~my-username/mysite_v1/about.php, it works fine. This proves the file does in fact exist and is available correctly to apache.
However - when I visit http://localhost/~my-username/mysite_v1/about, which should be remapped to the above URL, it fails with a 404 and the following message:
This proves the mod_rewrite rules are working fine, since its looking for about.php, not simply about. But for some reason, it seems convinced it does not exist when it definitely does.
Here is the configuration file apache uses for my user-specific sites:
The Options FollowSymlinks option is present, which is (apparently) required for mod_rewrite to work. But for some reason, it isnt. The same .htaccess file (all the same rewrites) work perfectly on my old windows machine.
I'm totally baffled as to what's going on here. This simply should be working. Does anyone have any ideas what is going on or what I may have overlooked, and is this a Leopard-specific issue maybe?
Additional details: I am using the version of Apache and PHP provided with Leo, not a 3rd party package or self-compiled version.
Edit: I should probably also mention that I have removed all occurances of Options MultiViews because I didnt want that behaviour as I do not use it on my production servers - and it was taking precedence over the rewrites.
- In my ~/Sites folder, I have a folder called mysite_v1, which contains several PHP files and a .htaccess file with the following contents:
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=40]
RewriteRule ^portfolio$ portfolio.php [QSA,L]
RewriteRule ^portfolio/$ portfolio.php [QSA,L]
RewriteRule ^portfolio/(.*$) portfolioview.php?proj=$1 [QSA,L]
RewriteRule ^about$ about.php [QSA,L]
RewriteRule ^contact$ contact.php [QSA,L]
- All the files required by the rewrites exist in the same folder.
- When I visit http://localhost/~my-username/mysite_v1/about.php, it works fine. This proves the file does in fact exist and is available correctly to apache.
However - when I visit http://localhost/~my-username/mysite_v1/about, which should be remapped to the above URL, it fails with a 404 and the following message:
Not Found
The requested URL /Users/my-username/Sites/mysite_v1/about.php was not found on this server.
This proves the mod_rewrite rules are working fine, since its looking for about.php, not simply about. But for some reason, it seems convinced it does not exist when it definitely does.
Here is the configuration file apache uses for my user-specific sites:
Code:
<Directory "/Users/my-username/Sites/">
Options Indexes FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
AccessFileName .htaccess
The Options FollowSymlinks option is present, which is (apparently) required for mod_rewrite to work. But for some reason, it isnt. The same .htaccess file (all the same rewrites) work perfectly on my old windows machine.
I'm totally baffled as to what's going on here. This simply should be working. Does anyone have any ideas what is going on or what I may have overlooked, and is this a Leopard-specific issue maybe?
Additional details: I am using the version of Apache and PHP provided with Leo, not a 3rd party package or self-compiled version.
Edit: I should probably also mention that I have removed all occurances of Options MultiViews because I didnt want that behaviour as I do not use it on my production servers - and it was taking precedence over the rewrites.