I'm trying to get FuelPHP to work on my server. I don't have access to use .htaccess file for RewriteRule. However, my host has allowed me to specify a part of the httpd.conf file.
The following works for what I want:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/username/public>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</Directory>
However, I need it to work for more than just "username" in there. How can I use wildcards with this Directory so that it works for any values of "username" for a one-time solution?
I found this advice on the apache manual, but I'm not sure how to get it to work with the RewriteRule
.
Tried the following but it didn't work:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</Directory>
Please help!
You were close with the apache manual:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public>
to
<Directory ~ "/Applications/XAMPP/xamppfiles/htdocs/sandbox/.*/public">
We found this message that addressed the problem we had, with no real solution provided: How to use apache2 mod_rewrite within a Directory directive that uses wildcards?
We ended up using the following solution:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(/sandbox/([^/]*)/public/.*)$ /sandbox/$2/public/index.php?$1 [PT,QSA]
The "PT" had to be added, as it is normally implied within directory blocks, and tells it to treat the target path as a URI instead of as a file path (which won't work since it's not getting the full local path). The QSA flag just makes sure your index.php gets handed all the information originally submitted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With