2013-12-14 45 views
0

那裏。 我是新的htaccess。 請幫我寫2 URL重寫這些鏈接php htaccess重寫helpME請

網址:??

  • 網址 - index.php頁面=新聞
  • 網址 - index.php頁面=用戶&暱稱=名稱
  • 網址 - 的index.php貓=範疇
  • 網址 - 的index.php貓=範疇& SEO鏈接=標題
  • 網址 - 的index.php貓=範疇& sub_cat =子類別
  • 網址 - 的index.php貓=範疇& sub_cat =子類別& SEO鏈接=標題
  • 網址 - ?index.php頁面=畫廊&專輯= ALBUMNAME
  • 網址 - 的index.php ?頁=畫廊&專輯= ALBUMNAME &圖像= imageName

需要進行網址的:

  • page.com/new S/
  • page.com/user/nickname/
  • page.com/it-news/
  • page.com/it-news/old/title/
  • page.com/it-news/ title/

就是這樣的。 非常感謝。 :)

回答

0

一個例子

RewriteEngine On # Turn on the rewriting engine 
RewriteRule ^news/?$ index.php?cat=news [NC,L] 

請注意!你最有modrewrite活躍在Apache 你可以進一步閱讀here

+0

這隻涵蓋了他需要的規則之一。 –

1

在你的主目錄中創建一個文件,並把它放在它的代碼。調用文件.htaccess

RewriteEngine On # Turn on the rewriting engine 
RewriteRule ^([A-Za-z0-9_-]+)/?([A-Za-z0-9_-]+)?/?$ index.php?cat=$1&page=$2 [NC,L] 

與數字和字母的括號是什麼是允許的,什麼是括號,然後會去給貓=其中$1是在您的網址變量。第二個支架將會到達$2的位置。因此,例如,如果您在瀏覽器中鍵入/it-news,它實際上會加載index.php?cat=it-news&page=,如果您輸入/it-news/datahere,它實際上會加載index.php?cta=it-news&page=datahere。每一個 ?在代碼中意味着它不需要在那裏,或者在那裏存在一次或不存在。 ()按順序回叫$ 1 $ 2 $ 3

希望這有助於!

+0

這不適用於我的結局:( – elibyy

+0

當您嘗試它時發生了什麼? –

+0

我得到500錯誤 – elibyy