Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用get请求进行mod重写_Php_.htaccess_Mod Rewrite - Fatal编程技术网

Php 使用get请求进行mod重写

Php 使用get请求进行mod重写,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,我在传递get变量时遇到问题 index?p=calendar指位于pages/calendar.php中的calendar.php。php和index.php位于根目录中 我的URL是localhost/researchportal/calendar/11/2011 日历有两个get变量,月和年。i、 ecalendar.php?月=11年=11 这是我的规则,但它不起作用 RewriteRule ^calendar/([0-9]+)$/([0-9]+)$ index.php?p=cal

我在传递get变量时遇到问题

index?p=calendar
指位于
pages/calendar.php中的
calendar.php
。php
index.php
位于根目录中

我的URL是
localhost/researchportal/calendar/11/2011

日历有两个get变量,月和年。i、 e
calendar.php?月=11年=11

这是我的规则,但它不起作用

RewriteRule ^calendar/([0-9]+)$/([0-9]+)$    index.php?p=calendar&month=$1&year=$2 [L]
我也试过了

RewriteRule ^calendar/([0-9]+)$/([0-9]+)$    pages/calendar.php?month=$1&year=$2 [L]
.htaccess文件

RewriteEngine On
RewriteBase /researchportal/
RewriteRule ^/calendar/([0-9]+)$ index.php?p=calendar [QSA,L]

RewriteRule ^users/login /researchportal/pages/login.php [L]
RewriteRule ^users/logout /researchportal/pages/logout.php [L]
RewriteRule ^users/register logout.php [L]

RewriteRule ^profile/([0-9]+)$ index.php?p=profile&usr_id=$1 [QSA,L]
RewriteRule ^profile/edit/([0-9]+)$ index.php?p=edit&usr_id=$1 [L]
RewriteRule ^([A-Za-z0-9-_]+)$ index.php?p=$1 [L]
^日历/([0-9]+)$/([0-9]+)$

你为什么要两次结束($)呢

^
开始表达式,然后
$
结束表达式。在表达式的中间没有任何理由。

RewriteRule ^calendar/([0-9]+)/([0-9]+)$    pages/calendar.php?month=$1&year=$2 [L]

应该会更好。如果出于某种原因,您还希望url中包含一些查询变量,那么您也可以将
[L]
替换为
[L,QSA]

我认为问题在于您还有一个$character

RewriteRule ^calendar/([0-9]+) *$* /([0-9]+)$    index.php?p=calendar&month=$1&year=$2 [L]

我对mod rewrite有点陌生,我认为$是表达式的一部分。现在我知道它结束了这个表达。