我想添加在本地环境(localhost)和我的liveserver上工作的重写器。
为什么?
当我在本地测试我的项目并将其上传到liveserver时,我不想改变规则。
(http:) //localhost/myproject/development/index.php?page=login时,它会将我发送到本地开发环境的根目录。但是加法行中的URL没有改变。- Maybe it has something todo with that "RewriteBase"?
- Do i have to set a basepath?
我的.htacces位于这里:
//localhost/myproject/development/.htaccess稍后,我还希望更改如下所示的路径:
(ANY-URL)index.php?page=somepage&second=hello&third=world&fourth=cool另外,我正在寻找一种在这两种环境中都能工作的解决方案。
发布于 2015-10-10 09:04:31
由于htaccess位于子目录中,所以请使用RewriteBase。
RewriteEngine On
RewriteBase /myproject/development/一旦完成,就可以在php/html文件中使用base元素。这将解析页面中脚本/样式表的地址。
<base href="/myproject/development/" />现在,htaccess中的重写将是:
RewriteRule ^((?!index\.php)[^/]+)/?$ index.php?page=$1 [L]https://stackoverflow.com/questions/33045018
复制相似问题