2013-10-19 128 views
1

我的網站重寫它有一個像http://domain.com/index.php?page=events/eventdetails/1/Silver+Jubileehttp://domain.com/index.php?page=events/announcementdetails/2http://domain.com/index.php?page=events/announcementdetails/3網址等,我想更改爲http://domain.com/Events/Eventdetails/1/Silver+Jubileehttp://domain.com/Announcements/Announcementdetails/3刪除URL部分,並與htaccess的

目前我的htaccess文件如下所示,我正在做一些其他頁面的URL重寫。

Options +FollowSymLinks 
RewriteEngine On 
RewriteRule AboutUs$ /index.php?page=home/aboutus [QSA,L] 
RewriteRule Announcements$ /index.php?page=events/announcements [QSA,L] 
RewriteRule Church-Officials$ /index.php?page=account/official [QSA,L] 
RewriteRule PhotoGallery$ /index.php?page=gallery/album [QSA,L] 
RewriteRule VideoGallery$ /index.php?page=videogallery/videos [QSA,L] 
RewriteRule ContactUs$ /index.php?page=home/contactus [QSA,L] 
RewriteRule Vicar-Message$ /index.php?page=events/allmessages [QSA,L] 
RewriteRule Events$ /index.php?page=events/event [QSA,L] 
RewriteRule Gallery-Images$ /index.php?page=gallery/photos [QSA,L] 

RewriteRule ^/(.*)$ /index.php?page=$1 [QSA,L] 

如何使用htaccess來完成?任何人都可以幫助我做到這一點。提前致謝。

回答

0

這在Web根目錄/

RewriteEngine on 
RewriteBase/

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /index\.php\?page=([^\s]+) [NC] 
RewriteRule^http://domain.com/%1 [R=301,L] 

RewriteCond %{THE_REQUEST} !^[A-Z]{3,}\ /index\.php [NC] 
RewriteRule ^(.*)$ index.php?page=$1 [QSA,L] 
+0

NOP添加到您的.htaccess。它顯示頁面未找到錯誤頁面。 – Jenz

+0

您使用的瀏覽器URL是什麼?如果'index.php'的'page'參數區分大小寫,你需要小寫你的目錄名稱(在URL中)。 –