Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 url重写动态url中的trobule_Php_.htaccess_Url_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php url重写动态url中的trobule

Php url重写动态url中的trobule,php,.htaccess,url,mod-rewrite,url-rewriting,Php,.htaccess,Url,Mod Rewrite,Url Rewriting,我正在使用.htaccess文件重新写入URL,并使用.htaccess文件更改某些URL,如下所示:- RewriteRule ^home/?$ index.php [NC,L] 但我不知道如何更改此url /localhost/mywebiste/complete_listing.php?category=Education&city=delhi 输入此URL /localhost/mywebiste/education-in-delhi url中的每个类别和城市 我试试

我正在使用.htaccess文件重新写入URL,并使用.htaccess文件更改某些URL,如下所示:-

RewriteRule  ^home/?$ index.php   [NC,L]
但我不知道如何更改此url

/localhost/mywebiste/complete_listing.php?category=Education&city=delhi
输入此URL

/localhost/mywebiste/education-in-delhi
url中的每个类别和城市

我试试这个:

Rewrite-rule  ^Agriculture-in-jaipur([A-Za-z0-9-]+)?$ complete_listing.php?category=education&&city=delhi [NC,L]

但是通过这种方式,我每次更改类别和城市时只更改一种类型的URL

如果我是对的,您希望获得/localhost/mywebiste/教育-在-德里-包含两个变量的URL

RewriteRule  ^([A-Za-z0-9-]+)-in-([A-Za-z0-9-]+)$ complete_listing.php?category=$1&city=$2 [NC,L]
请注意末尾的
L
-这将是应用的最后一条规则。

该代码将返回
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)-in-(.*)$ complete_listing.php?category=$1&city=$2 [NC,L]


感谢您的帮助,但url类别中存在一个问题,即“有空间”,它的注释正在工作,谁可以从Jaipur的url自行车%20Service%20Center中删除%20您必须删除空间,即,
$string=str_replace(“”,,$string)感谢您的帮助,但url类别中有一个问题,即“是否有空间”&它的注释正在工作,我可以从斋浦尔的url自行车%20服务%20中心删除%20吗
RewriteEngine On
RewriteRule ^([^-]*)-in-([^-]*)\.html$ /mywebiste/complete_listing.php?category=$1&city=$2 [L]