我正在尝试让 FuelPHP 在我的服务器上工作。我无权将 .htaccess 文件用于 RewriteRule。但是,我的主机允许我指定 httpd.conf 文件的一部分。
以下适用于我想要的:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/username/public>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</Directory>
但是,我需要它的作用不仅仅是“用户名”。 如何在此目录中使用通配符,以便它适用于一次性解决方案的任何“用户名”值?
我在 apache manual 上找到了这个建议,但我不知道如何让它与
RewriteRule
一起工作.尝试了以下但没有奏效:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</Directory>
请帮忙!
最佳答案
你很接近 apache 手册:
<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public>
到
<Directory ~ "/Applications/XAMPP/xamppfiles/htdocs/sandbox/.*/public">
关于unix - 带有 Apache Directory 和 RewriteRule 的通配符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9203354/