我使用Apache 2.2和mod_rewrite。我想採取以下網址並將它們映射到另一個網址。該模式是簡單和這樣的:modrewrite RewriteRule問題
http://domain/test/ex1.html - >http://domain/app/index.php/content/?name=ex1
我試圖在一個.htaccess中(發生在/測試/目錄中的文檔根):
RewriteEngine On
RewriteBase /app/
RewriteRule (.*)\.html index.php/content/?name=$1
和
RewriteEngine On
RewriteRule (.*)\.html /app/index.php/content/?name=$1
我不確定反向引用是否正確,因此設置爲$ 0和$ 2,但似乎沒有幫助。
我也試過RewriteLogLevel設定到9
有一個步驟,其中它幾乎有: 重寫 'ex1.html' - > '?的index.php /內容/名稱= EX1'
重寫日誌的最後一行如下: [perdir /無功/網絡/域/ htdocs中/測試/]內部重定向與/app/index.php/content/ [INTERNAL REDIRECT]
如何能我得到這個重寫爲/app/index.php/content/?name=ex1?
編輯 因此使用此作爲文檔根目錄文件的.htacces爲RedirectMatch工作:
RewriteEngine On
RewriteBase/
RedirectMatch ^(.*)/(.*)\.html$ http://domain/app/index.php/content/?name=$2
#this doesnt work - adding to docroot allows for it to pick up but still using test/ex1 rather than just ex1
#RewriteRule ^(.*)\.html$ /app/index.php/content/?name=$1
任何越來越底部重寫規則(當前註釋掉)工作的幫助將不勝感激。
感謝
嗯....重讀我原來的文章,因爲這似乎並沒有工作。我假設這將是一個位於docroot的.htaccess文件?由於某種原因,它仍然無法正常工作。呃.. – timpone 2010-05-25 22:31:23
反向引用它通過目錄的測試,所以test/ex1而不是僅僅插入$ 1的ex1。 thx任何幫助 – timpone 2010-05-26 01:46:27