1

我想为我的网站创建 seo 友好的 url。我想从 .htaccess 文件创建它。我对 .htaccess 知之甚少

我有以下网址 http://www.testsite.com/index.php?dispatch=flowers_search.flowers_search_result&city=Pune&type=Carnation

我需要显示如下网址, http://www.testsite.com/flowers/Pune/Carnation

谢谢

4

3 回答 3

2

http://www.generateit.net/mod-rewrite/

导致:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?dispatch=flowers_search.flowers_search_result&city=$1&type=$2 [L]
于 2012-08-18T13:37:47.673 回答
0

Just Try With the following :

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?dispatch=$1&city=$2&type=$3 [L]

I think this may help you to resolve your problem.

于 2013-01-05T13:21:59.427 回答
0
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . /index.php?args=%{REQUEST_URI} [L]
</IfModule>

这会将您的查询字符串放入一个变量中,您可以在页面上将其用作$_GET['args']. 所以你打电话:

http://www.testsite.com/flowers/Pune/Carnation

但你真的在显示页面:

http://www.testsite.com/?args=flowers/Pune/Carnation

然后,您可以根据需要获取$_GET['args']并解析它,例如:

$args = explode('/', $_GET['args']);
array_shift($args); // this take an empty value off of the first item in the array
$dispatch = $args[0];
$city = $args[1];
$type = $args[2];

等等。

于 2012-08-18T13:55:02.663 回答