[英]Removing part of the URL with htaccess
這是我的應用程序的結構:
- app/
- routes/
- views/
- start.php
- public/
- css/
- js/
- index.php
- .htaccess
我正在使用Slim
作為PHP框架。
目前,由於我的index.php
位於public
目錄中,因此我的URL必須看起來像這樣:
http://www.mywebsite.com/public/about
我該如何重寫URL,使其等同於上述內容:
http://www.mywebsite/about
我已經閱讀了有關此內容的內容,並將其作為常見的答案:
RewriteRule ^public/(.*)$ /$1 [NC,L,R]
我試過了,但是沒有用。 這是我得到的錯誤:
The requested URL /home was not found on this server.
嘗試這個 :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ /public/$1 [NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.