如何用.htaccess將http://mysite.net/test/index.php/welcome/index重寫爲http://mysite.net/test/mainpage.html?我用下面的代碼,但找不到網頁的錯誤occours使用htaccess的url重寫
RewriteEngine On
RewriteRule [mainpage]?.html$ index.php/welcome/index [L]
如何用.htaccess將http://mysite.net/test/index.php/welcome/index重寫爲http://mysite.net/test/mainpage.html?我用下面的代碼,但找不到網頁的錯誤occours使用htaccess的url重寫
RewriteEngine On
RewriteRule [mainpage]?.html$ index.php/welcome/index [L]
你有你的訂貨翻轉:
RewriteEngine On
RewriteBase/
RewriteRule test/index.php/welcome/index test/mainpage.html [L]
此外,[mainpage]?
的小心,因爲你已經得到它指定爲一個範圍(即任何一個字符'm','a','i'等都會匹配),我想你的意思是匹配整個字符串。
使用以下流程: 只需點擊Wamp圖標。
WAMP>>
WAMP>>APACHE
WAMP>>APACHE>>httpd.conf
公開賽在notepad.Find該文件下面的代碼
#LoadModule rewrite_module modules/mod_rewrite.so
通過刪除#符號
LoadModule rewrite_module modules/mod_rewrite.so
那輕鬆改寫它的代碼。最後保存該文件
感謝您的回覆。我試過這段代碼,但仍然出現錯誤代碼 – rohit
哪個目錄是您的'.htaccess'文件?如果你的'.htaccess'在test目錄下,你需要將'test /'部分從'RewriteRule'中取出,並將'RewriteBase'改爲'/ test' – stevevls