1

私は自分のウェブサイトに seo フレンドリーな URL を作成したいと考えています。.htaccess ファイルから作成したい。.htaccess に関する知識がほとんどない

私は次のURLを持っています http://www.testsite.com/index.php?dispatch=flowers_search.flowers_search_result&city=Pune&type=Carnation

次のように URL を表示する必要があります 。 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
<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 に答える
0

以下を試してみてください:

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

これはあなたの問題を解決するのに役立つかもしれないと思います.

于 2013-01-05T13:21:59.427 に答える