我想为我的网站创建 seo 友好的 url。我想从 .htaccess 文件创建它。我对 .htaccess 知之甚少
我需要显示如下网址, http://www.testsite.com/flowers/Pune/Carnation
谢谢
我想为我的网站创建 seo 友好的 url。我想从 .htaccess 文件创建它。我对 .htaccess 知之甚少
我需要显示如下网址, http://www.testsite.com/flowers/Pune/Carnation
谢谢
http://www.generateit.net/mod-rewrite/
导致:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?dispatch=flowers_search.flowers_search_result&city=$1&type=$2 [L]
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.
<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];
等等。