传递变量类型,虽然mod-rewrite变量、类型、rewrite、mod

2023-09-02 11:40:21 作者:不俗

您好我有htaccess的mod_rewrite的一个问题,也许这里有人会指出,在正确的方向。

我的网站有1个主文件[index.php文件]中的所有导航是通过URL字符串传递瓦尔做如

 的index.php?页=约
 

这是工作确定我的.htaccess [下文]

  domain.com/about
 
Nginx Rewrite概述与正则表达式

某些页面有第二个变量,例如

  index.php页面=事件和放大器;?事件ID = 42
 

这也工作与下面的.htaccess

  domain.com/event/42
 

我的问题是,我有需要瓦尔得如

等其他页面

  index.php页面=新闻与?NewSID的= 4
domain.com/news/42

?index.php页面=地图和放大器; venueID = 4
domain.com/map/42
 

是否有可能这样做吗?

在此先感谢

.K

的.htaccess

 选项+了FollowSymLinks

RewriteEngine叙述上

重写规则^([^ / 。] +)/ * $ /index.php?page=$1 [L]
重写规则^([^ / 。] +)/ *([^ / 。] +)/ * $ /index.php?page=$1&eventType=$2 [L]
 

解决方案

当然,只是做

 重写规则^([^ / 。] +)/ * $ /index.php?page=$1 [L]
重写规则^事件/([^/.]+)/*$ /index.php?page=event&eventType=$1 [L]
重写规则^新闻/([^/.]+)/*$ /index.php?page=news&newsID=$1 [L]
重写规则^地图/([^/.]+)/*$ /index.php?page=map&venueID=$1 [L]
 

Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point in the the right direction.

my site has 1 main file [index.php] all the navigation is done by passing vars in the url string eg

index.php?page=about

this is working ok with my .htaccess [below]

domain.com/about

some of the pages have a second variable eg

index.php?page=event&eventID=42

this works too with the .htaccess below

domain.com/event/42

my problem is that I have other other pages that require vars too eg

index.php?page=news&newsID=4
domain.com/news/42

index.php?page=map&venueID=4
domain.com/map/42

Is it possible to do this ?

Thanks in advance

.k

.htaccess

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^/.]+)/*$ /index.php?page=$1 [L]
RewriteRule ^([^/.]+)/*([^/.]+)/*$ /index.php?page=$1&eventType=$2 [L]

解决方案

Sure, just do

RewriteRule ^([^/.]+)/*$ /index.php?page=$1 [L]
RewriteRule ^event/([^/.]+)/*$ /index.php?page=event&eventType=$1 [L]
RewriteRule ^news/([^/.]+)/*$ /index.php?page=news&newsID=$1 [L]
RewriteRule ^map/([^/.]+)/*$ /index.php?page=map&venueID=$1 [L]

 
精彩推荐