在 URL 重写动态 URL 时面临麻烦


facing trobule in url-rewriting a dynamic url

我正在使用.htaccess文件进行URL重写,我使用.htaccess文件更改了一些URL:-

RewriteRule  ^home/?$ index.php   [NC,L]

但我不知道我如何更改此网址

/localhost/mywebiste/complete_listing.php?category=Education&city=delhi

到此网址中

/localhost/mywebiste/education-in-delhi

网址中的每个类别和城市。

我试试这个:

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

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

如果我

是对的,你想得到/localhost/mywebiste/education-in-delhi - 带有 2 个变量的网址

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]

该代码将返回http://www.example.com/Education-in-delhi.html

RewriteEngine On
RewriteRule ^([^-]*)-in-([^-]*)'.html$ /mywebiste/complete_listing.php?category=$1&city=$2 [L]