何よりも前に、私は研究してきましたが、まだこの問題の解決策を見つけていないと言いたいです.
目に見えないリダイレクトをしたい。この URL http://www.localhost.com/@user_name/search/?q=stringを使用して、別のページにリダイレクトせずに検索を実行します。ユーザーを取得するには、MySQL データベースでユーザー @user_name を確認する必要があるためです。プロフィール。
PHP スクリプト search.php
<?php
echo 'USER:'.$_GET['user'].'<br/>';
echo 'QUERY q:'.$_GET['q'].'<br/>';
?>
.htaccess
#Begin invisibly redirect
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
#This works with this (www.localhost.com/@user_name/search/X55)
#RewriteRule ^@([_A-Za-z0-9]+)/search/X(.*)$ /profile/search/search.php?user=$1&q=$2 [L]
#But ,for search, this doesn't work with this (www.localhost.com/@user_name/search/?q=string)
RewriteRule ^@([_A-Za-z0-9]+)/search/?q=(.*)$ /profile/search/search.php?user=$1&q=$2 [L]
#END invisibly redirect
結果
1
使用: #RewriteRule ^@([_A-Za-z0-9]+)/search/X(.*)$ /profile/search/search.php?user=$1&q=$2 [L]
AND
www.localhost. com/@user_name/search/X55
返される
USER:user_name
QUERY q:55/
2
使用: #RewriteRule ^@([_A-Za-z0-9]+)/search/?q=(.*)$ /profile/search/search.php?user=$1&q=$2 [L]
AND
www. localhost.com/@user_name/search/?q=string
サーバーエラーになります。
助けてください、ありがとう。