簡體   English   中英

使用htaccess刪除部分URL

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM