Htaccess Revert URL Encoding
Facebook, and twitter rewri开发者_如何学Pythonte urls and replace characters(like ? or /) with code.
Original URL - http://example.com/article.php?title=hi/how-are-you?
URL after(social network redirect): http://example.com/article.php?title=hi%2Fhow-are-you%3F
I use a hosted comment system(Disqus) which uses the URL as the thread identifier, which means I will get two threads for one page because of this variation.
Is there anyway that I can revert the characters through htaccess or another method?
You could use rawurldecode
.
You can get the right line back with php-function:
$_GET['title'] = urldecode($_GET['title']);
So you can pass all urls thorough some rewriter.php with this function via .htaccess. .htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*)$ /rewriter.php [QSA]
rewriter.php:
<?php
$_GET['title'] = urldecode($_GET['title']);
include('index.php');
?>
This method allows to use some statistics, redirects or other manipulations.
精彩评论