【发布时间】:2013-12-28 16:17:09
【问题描述】:
我正在使用 Restler 在 Apache 服务器上构建 REST API,但我遇到了一些 url 重写问题。
这是我的目录:
/api:
/供应商
...
.htaccess(第一级)
/公共:
/示例
/测试
/src
.htaccess(第二级)
/探险家:
/css
/图片
/lib
index.html
现在,这就是我想要的:
1)我想要一个不可见的“公共”目录。
例如,像 GET mydomain.com/api/data 这样的请求会将其直接选择到 mydomain.com/api/public/data
2)我希望“公共”目录的根目录是 explorer/index.html 但是这个文件以相对的方式加载了很多资源,有时它不加载。
所以基本上我想访问 /api/public/explorer/index.html 并加载所有资源,如果我只尝试访问:mydomain.com/api
这是我现在拥有的:
Options +FollowSymLinks
AddDefaultCharset UTF-8
RewriteEngine On
RewriteBase /api/
RewriteCond %{REQUEST_URI} !^public/
RewriteRule ^(.*)$ /api/public/$1
对于一级.htaccess,似乎效果不错
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/$ explorer/ [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
<IfModule mod_php5.c>
php_flag display_errors On
</IfModule>
对于二级.htaccess
有什么建议吗?谢谢
【问题讨论】:
标签: php apache .htaccess url-rewriting restler