传递变量类型,虽然mod-rewrite [英] Passing variable types though mod-rewrite

查看:181
本文介绍了传递变量类型,虽然mod-rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

 的index.php?页=约
 

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

  domain.com/about
 

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

  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]

这篇关于传递变量类型,虽然mod-rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆