システムについて
プロジェクトにこの形式の URL があります:-
http://project_name/browse_by_exam/type/tutor_search/keyword/class/new_search/1/search_exam/0/search_subject/0
ペアkeyword/class
は「クラス」キーワードで検索することを意味します。
以下は私のhtaccessファイルです: -
##AddHandler application/x-httpd-php5 .php
Options Includes +ExecCGI
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
############To remove index.php from URL
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
#################################################end of find a class
</IfModule>
プロジェクト内のすべてのモジュールに対して実行される共通の index.php ファイルがあります。URL から index.php を削除するための書き換えルールしかありません (上記を参照)。
$_GET 配列を定義するために htaccess 書き換えルールを使用していません。私は代わりにそれを行うPHP内のURLパーサー関数を持っています。私が示した URL の例では、パーサーは以下を返します:-
Array ( [a] => browse_by_exam [type] => tutor_search [keyword] => class [new_search] => 1 [search_exam] => 0 [search_subject] => 0 )
検索 URL の準備中に urlencode() を使用し、検索 URL の読み取り中に urldecode() を使用しています。
問題
URL の一部の文字に問題があります
Character Response
% 400 - Bad Request - Your browser sent a request that this server could not understand.
/ 404 - Not FOund
\ # + Page does not break but urldecode() removes these characters.
これらすべての文字を許可したい。何が問題なのですか?これらを許可するにはどうすればよいですか? 助けてください、ありがとう、サンディーパン
アップデート
現在、/ 文字のみが URL の破損を引き起こしています (以前と同様に 404 エラー)。そこで、URL 内の index.php を非表示にする htaccess 書き換えルールを削除して、代わりに完全な URL を使用してみました。検索用語class/new
として、次の 2 つの URL を試してみました:-
http://project_name/index.php?browse_by_exam/type/tutor_search/keyword/class%2Fnew/new_search/1/search_exam/0/search_subject/0
http://project_name/index.php/browse_by_exam/type/tutor_search/keyword/class%2Fnew/new_search/1/search_exam/0/search_subject/0
そして、最初のものは機能しますが、2番目のものは機能しません。index.php?browse_by_exam
最初のものに注目してください。
しかし、私は最初の URL 規則を使用できません。index.php を非表示にして作成/操作する必要があります。助けてください
ありがとうございます
編集 (解決済み)
私の他の質問に対するボビンスの答えを考える
urlencoded スラッシュは URL を壊し
ています。次のような URL を使用するのが最善だと思います:-
http://project_name/browse_by_exam?type/tutor_search/keyword/class
%2Fnew/new_search/1/search_exam/0/search_subject/0
そうすれば、慣例による読みやすさの難しさを取り除き、次¶m1=value1¶m2=value2
を使用してクエリ文字列部分でスラッシュを許可することもできます?
ボビンスが言ったので、AllowEncodedSlashesを避けたいAlso some tools or spiders might get confused by it. Although %2F to mean / in a path part is correct as per the standard, most of the web avoids it.