如何修改这个MOD改写成我想要的网址是什么? [英] how to modify this mod rewrite into the url I want?
问题描述
我居然得到的回答是,如果我想改变我的网址,从 www.mydomain.com/laravel4/public/posts
到 WWW。 mydomain.com/posts
I actually got an answer that if I want to change my url from www.mydomain.com/laravel4/public/posts
into www.mydomain.com/posts
这是我必须做我的的.htaccess
RewriteEngine On
RewriteRule !^laravel4/public/ /laravel4/public%{REQUEST_URI} [L,NC]
但我还有一个问题,如果我想的网址是 www.mydomain.com/laravel4/posts
这需要在公众应该怎么修改?我以为取出laravel4在code以上会工作,但似乎并不那么容易:(
but I have another question if I want the url to be www.mydomain.com/laravel4/posts
which takes out the public what should I modify? I thought taking out the laravel4 in the code above would work but doesn't seem that easy :(
推荐答案
在理想情况下,你应该将Laravel安装了文档根的,只是公共文件夹的内容移动到您的文档根目录并编辑index.php文件和自举/paths.php据此,或者设置文档根到Laravel的公共文件夹,如果你打开一个支持票某些主机会更改文档根目录给你。
Ideally you should move the Laravel install out of the document root and just move the contents of the public folder into your document root and edit the index.php and bootstrap/paths.php accordingly, or alternatively set the document root to the public folder of Laravel, some hosts will change the document root for you if you open a support ticket.
不过那并不总是可能取决于你的主机上,大多数人会告诉你去,并且找到更好的主机,但同样,多数民众赞成并不总是一个选择。
However thats not always possible depending on your host, and most people will tell you to go off and find a better host, but again, thats not always an option.
下面是一个例子的.htaccess,你可以用它来重写所有URL到Laravel的公共/ index.php文件,但被警告,这不是设置Laravel一个非常安全的方式,任何人都可能会访问你的任何存在于您的文档根目录的配置和其他文件,揭露你的数据库的密码和密钥用于加密。
Below is a .htaccess example you can use to rewrite all URLs to the public/index.php of Laravel, but be warned, this isn't a very secure way to setup Laravel, and anyone could potentially access any of your configuration and other files that exist in your document root, exposing your database passwords and secret keys used to encryption.
RewriteEngine On
RewriteRule ^ laravel4/public/index.php [L]
更新为每个请求
Updated as per request
RewriteEngineOn
RewriteRule ^laravel4/.* laravel4/public/index.php [L]
这篇关于如何修改这个MOD改写成我想要的网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!