我想從我的網址中刪除公用文件夾和index.php。如何從ZF2中刪除public和index.php
例 我當前的URL看起來像
http://localhost/elibrary/public/
我想刪除公共和我的URL應該看起來像
http://localhost/elibrary/
我的.htaccess文件包含的內容。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /elibrary/
## Adding a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} \s/+(.+?[^/])[?\s] [NC]
RewriteRule^/%1/ [L,R=301]
# remove /public/ from URL
RewriteCond %{REQUEST_URI} !/public/ [NC]
RewriteRule ^(.*?)/?$ public/$1 [L]
我看了這篇文章.htaccess: remove public from URL並且提出了上面的.htaccess文件。這個.htaccess文件成功移除了公共文件夾,但是所有的網頁格式都像css一樣丟失了。 但是,當我嘗試這http://localhost/elibrary/index.php/
它顯示404頁,但所有格式化回來。
我怎樣才能成功地從我的網址中刪除公共和index.php?我使用Zend框架2
我改變.haccess文件按照上述建議。但它顯示我在瀏覽器中的文件和目錄列表。如果我點擊公共文件夾,它會打開網站。爲什麼上述解決方案不適合我。 –
檢查這篇文章http://stackoverflow.com/questions/9834328/how-to-remove-public-from-url-using-routeing-in-zend-framework –