2013-08-21 35 views
0

我有一些問題給你,請原諒我。當我想將我的網站重定向到另一個位置時,我遇到了一些麻煩。一個網址我也想是這樣的:如何使用.htaccess從子文件夾重定向?

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

我想我的默認網址重定向到這裏:

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

的.htaccess代碼:

Redirect 301 public/

即時通訊使用laravel框架

回答

1

把你的.htaccess文件中的「公共」文件夾:

 RewriteEngine on 
    RewriteRule (.*)$ /mywebsite/$1 [R=301,L] 
+0

多數民衆贊成在工作很好:)非常感謝 –

0

如果您希望重定向是透明的,即/public仍然隱藏在URL中,請不要執行301,因爲它會執行外部重定向。改爲使用以下RedirectRule

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

這從/mywebsite/public/page.html服務/mywebsite/page.html默默。

+0

多數民衆贊成在我的網頁不能正常工作,我得到500服務器錯誤,你有別人的想法? –

+0

如何使用rewriterule? –

+0

@ArryanggaAlievPratamaputra添加我剛剛更新的重寫條件。 –

相關問題