簡體   English   中英

使用index.php管理我站點中的所有url路徑

[英]Using index.php to manage all url paths in my site

我必須遺漏一些明顯的東西,因為這似乎不應該是一個難題。 我希望通過我的網站上的所有網址路徑( http://example.com : http://example.com/adminhttp://example.com/happy/happy/joy/joy等)進行處理我的index.php。 我以前見過這個,但是我不知道怎么做。

只需在根目錄中創建一個.htaccess文件:

# Turn on URL rewriting
RewriteEngine On

# Base directory
RewriteBase /

# Protect hidden files from being viewed
<Files .*>
    Order Deny,Allow
    Deny From All
</Files>

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

Apache標志解釋:

[L] - “Last”的別名,指示服務器重寫規則已經結束,是時候執行內部重定向而不更改瀏覽器的uri。

[PT] - “Pass Through”的別名,允許將Mod_Rewrite操作的uri傳遞給下一種類型的處理程序,相應於php.ini模塊的包含順序。 根據主題有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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