簡體   English   中英

在Apache和PHP上進行URL重寫/ Mod重寫.htaccess

[英]URL Rewrite/Mod Rewrite .htaccess on Apache and PHP

我的網站上只有一個入口點

mysite.com/admin/index.php? View=List&Model=User

通過此index.php文件對數據庫/應用程序的所有訪問。

我想清除上面顯示的URL。

mysite.com/admin/ List/User

想法是刪除鍵“模型和視圖”。

我發現此鏈接看起來非常相似。

PHP / Apache:使用.htaccess重寫規則

在htaccess文件中插入以下代碼:

RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]

重寫的URL:

http://mysite.com/admin/List/User

該站點對於生成重寫URL非常有用

http://www.generateit.net/mod-rewrite/

如果還沒有以下內容,請在您的Web根目錄中創建一個名為.htaccess的文件:

# Turn the rewrite engine on (skip this if already done)
RewriteEngine On

# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]

這可能起作用:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]

添加到您網站的根文件夾中的.htaccess。

暫無
暫無

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

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