0

htaccessファイルでこのURL「www.domain.com/index.php?route=custom/static/page」を「www.domain.com/page」に書き換える方法は、基本的にはindex.php?route=を取り出したいだけですcustom/static/ URL から。

正規表現がわからないので、 http://www.generateit.net/mod-rewrite/を試しましたが、生成するだけです

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?route=$1 [L]

これは URL から「custom/static」を削除しません。他の例もいくつか試しましたが、index.php のみを削除しますか? 変数を渡さないので、助けていただければ幸いです。

4

1 に答える 1

2

mod-rewrite を使用する概念を知っていますか?

あなたの質問では、mod-rewrite を使用してリダイレクトすることについて言及しました

「www.domain.com/index.php?route=custom/static/page」、こちら$_Get['route']="custom/static/page"] $url_parameter=$_Get['route']

"www.domain.com/page" [ここでは $_Get['route']="page"],

$_Get['route'].したがって、取得したasの値に「custom/static/」を手動で追加できます。$url_parameter="custom/static"+$_Get['route'] //For PHP

mod_rewrite を使用すると、要求を満たすことができます。

RewriteEngine On
RewriteRule ^([^/]*)$ /index.php?route=$1 [L]

ただし、.htaccess を使用したすぐに使用できるソリューションが必要な場合は、生成ツールを使用する代わりに「rewrite-engine」を学習することをお勧めします。

于 2013-05-10T15:31:47.437 に答える