いくつかの書き換えルールを使用して、フォーラムの読み取り可能な URL を作成します。たとえば、「この新しい車についてどう思いますか?」という件名の新しいトピックを投稿したとします。私はこのようなリンクを作成します: forum/cars/51-Hey-what-do-you-think-of-this-new-car-?
51 はトピック ID です。
私の .htaccess では、次の書き換えルールを使用します。
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/([0-9-a-z]+)/?$ forum/list_topics.php?key=$1 [L]
RewriteRule ^forum/([0-9-a-z]+)/([0-9]+)?$ forum/list_topics.php?key=$1&page=$2 [L]
RewriteRule ^forum/([0-9-a-z]+)/([0-9]+)-(.*)/?$ forum/list_post.php?topic=$2 [L]
したがって、これらの文字を含む件名を投稿する場合を除いて、これは正常に機能しています: +"*ç%&/()=?'^
私はphp関数を使用してURLを作成します:
$url_topic = str_replace(' ', '-', $url_topic); //replace space with -
$url_topic = urlencode($url_topic);//encode url
この場合、 $url_topic の値は : です34-%2B%22%2A%C3%A7%25%26%2F%28%29%3D%3F%27%5E
が、クリックすると次のエラーが表示されます:
Not Found
The requested URL /forum/cars/34-+"*ç%&/()=?'^ was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
私は何が欠けていますか?
ありがとう