2012-02-06 128 views
1

我有一個入口點在我的網站URL重寫/現代重寫的.htaccess在Apache和PHP

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

到數據庫/應用的所有訪問都是通過這個index.php文件。

我想從上面顯示的內容中清除我的URL。

mysite.com/admin/List/User

的想法是刪除鍵「模式和‘查看’。

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

PHP/Apache: Rewrite rules with .htaccess

+0

無的選擇似乎上班。我有一種感覺我缺少一個模塊 – IEnumerable 2012-02-06 12:38:24

+0

LoadModule rewrite_module modules/mod_rewrite.so已啓用,是否還有其他模塊需要啓用? – IEnumerable 2012-02-06 12:40:24

回答

4
在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/

+0

我保存該鏈接! – IEnumerable 2012-02-06 12:41:00

1

中創建一個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] 
0

這可能會實現:

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

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