Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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 .htaccess中的不同重写规则_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php .htaccess中的不同重写规则

Php .htaccess中的不同重写规则,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我的htaccess中已经有此重写规则 RewriteCond $1 !^(index\.php) RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id_user=$1&page=$2 [L] http://www.mydomain.com/index.php?id_user=user&page=news http://www.mydomain.com/user/news.html 现在我对新闻细节和事件细节有一个问题 例如,您有

我的htaccess中已经有此重写规则

RewriteCond $1 !^(index\.php)
RewriteRule ^([^/]*)/([^/]*)\.html$ /index.php?id_user=$1&page=$2 [L]

http://www.mydomain.com/index.php?id_user=user&page=news
http://www.mydomain.com/user/news.html
现在我对新闻细节和事件细节有一个问题

例如,您有这样的url(仅适用于页面新闻):

和此(仅适用于页面事件)

我是否可以在htaccess中插入新规则以获取这些规则,或者我必须编辑我的规则

我的url对于所有查询都是相同的

index.php?id_user=user&page=details-news&category=category&title=title-news
or
index.php?id_user=user&page=event&title=title-event

任何帮助都将不胜感激

您的实际规则仅与以下内容匹配:

^([^/]*)/([^/]*)\.html$
网址

也就是说只有一个/里面。因此,您可以添加具有更多斜杠的其他规则,而无需修改此实际现有规则


唯一的问题是,如果您想使用一个/添加其他规则。但事实并非如此。

您可以使用以下规则:

# skip further rules for files/directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2 [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2&title=$3 [L,QSA]

RewriteRule ^([^/]+)/^([^/]+)/([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2&category=$3&title=$4 [L,QSA]
^([^/]*)/([^/]*)\.html$
# skip further rules for files/directories
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2 [L,QSA]

RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2&title=$3 [L,QSA]

RewriteRule ^([^/]+)/^([^/]+)/([^/]+)/([^/.]+)\.html$ /index.php?id_user=$1&page=$2&category=$3&title=$4 [L,QSA]