0

我有一个问题要问你,请原谅我之前。当我想将我的网站重定向到另一个位置时,我遇到了一些麻烦。我尝试的网址是这样的:

http://localhost/mywebsite/public/example.html  => Default URL

我想将我的默认网址重定向到这里:

http://localhost/mywebsite/example.html => What i want

我的.htaccess代码是:

Redirect 301 public /

我正在使用laravel框架

4

2 回答 2

1

将您的 .htaccess 文件放在“public”文件夹中:

     RewriteEngine on
     RewriteRule (.*)$ /mywebsite/$1 [R=301,L]
于 2013-08-21T03:53:03.120 回答
0

如果您希望重定向是透明的,即/public在 URL 中保持隐藏状态,请不要执行 301,因为它执行外部重定向。请改用以下内容RedirectRule

RewriteCond %{REQUEST_URI} !/public/ [NC]
RedirectRule ^mywebsite/(.*)$ mywebsite/public/$1 [NC,L]

/mywebsite/page.html将从/mywebsite/public/page.html.

于 2013-08-21T03:35:08.943 回答