5

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!

Nate Radebaugh
  • 787
  • 1
  • 15
  • 27

2 Answers2

8

You were close with the apache manual:

<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public>

to

<Directory ~ "/Applications/XAMPP/xamppfiles/htdocs/sandbox/.*/public">
vol7ron
  • 35,981
  • 19
  • 104
  • 164
  • can you tell whats wrong in this syntax. I get forbidden message: Alias /salt "/var/cache/salt/master/minions/.*/files" Options MultiViews FollowSymLinks Require all granted – Himanshu Jain Aug 17 '16 at 20:02
1

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.

Community
  • 1
  • 1
Nate Radebaugh
  • 787
  • 1
  • 15
  • 27