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+Jubilee , http://domain.com /公告/公告详情/3 .

目前我的 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 完成?谁能帮我做。提前致谢。

4

1 回答 1

0

将此添加到您.htaccess的 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]
于 2013-10-19T11:14:09.023 回答