Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Custom RewriteRule in .htaccess to hide ugly query string
I use this code to filter articles:
<txp:smd_if field="urlvar:base" operator="ge" value="1" filter="/[^0-9]+/" debug="0">
<txp:soo_article_filter width_cab="{smd_if_base}">
<txp:article limit="20" sort="title" />
</txp:soo_article_filter>
<txp:else />
<txp:article limit="20" sort="title" />
</txp:smd_if>
Here is my .htaccess:
AddDefaultCharset Off
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/base([0-9]+)/?$ $1?base=$2
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
When I open URL http://site.ru/sink/?base=60 – it works as expected. But openning http://site.ru/sink/base60
leads to TXP’s 404 error. It seems that TXP tries to parse this url and breaks. URL-mode is section/id/title
Rewriting works good – here is pretext
dump at url http://site.ru/sink/base60
:
[pretext] => Array
(
[id] =>
[s] =>
[c] =>
[q] =>
[pg] =>
[p] =>
[month] =>
[author] =>
[request_uri] => /moyka/base60
[qs] => base=60
[subpath] => \/
[req] => /moyka/base60
[status] => 404
[page] =>
[css] =>
[path_from_root] => /
[pfr] => /
[path_to_site] => /home/uxxx/site.ru/www
[permlink_mode] => section_id_title
[sitename] => My site name
)
I had another site and use the same technique but inside article, i.e. instead of using siteGood.ru/article/title?pg=2
(custom function of comments pagination) i use siteGood.ru/article/title/page2
. But in good example additional level is added after title of article and inside individual_article, not article_list. Just for help i dumped pretext
var at good url – http://uromax.ru/vopros-otvet/ask-urolog/page2 at another site:
[pretext] => Array (
[id] => 747
[s] => vopros-otvet
[c] =>
[q] =>
[pg] => 2
[p] =>
[month] =>
[author] =>
[request_uri] => /vopros-otvet/ask-urolog/page2
[qs] => pg=2
[subpath] => \/
[req] => /vopros-otvet/ask-urolog/page2
[status] => 200
[page] => default
[css] => default
[id_keywords] =>
[id_author] => ghost
[next_id] =>
[next_title] =>
[next_utitle] =>
[next_posted] =>
[prev_id] =>
[prev_title] =>
[prev_utitle] =>
[prev_posted] =>
[path_from_root] => /
[pfr] => /
[path_to_site] => /home/u78707/uromax.ru/www
[permlink_mode] => section_title
[sitename] => Урология
[secondpass] =>
)
How can i make TXP to parse url’s like http://site.ru/sink/base60 as “http://site.ru/sink + ?base=60” ?
Hope that described problem fully :)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
Re: Custom RewriteRule in .htaccess to hide ugly query string
Up if somebody can help :)
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#3 2010-06-23 14:42:16
- makss
- Plugin Author
- From: Ukraine
- Registered: 2008-10-21
- Posts: 355
Re: Custom RewriteRule in .htaccess to hide ugly query string
VERY bad idea, but this worked…
Add in index.php some IF
, preg_match
or preg_replace
and
$_SERVER['REQUEST_URI']="your result for URI"; $_SERVER["QUERY_STRING"]="your result for QUERY_STRING";
ps: Is there other decision?
Last edited by makss (2010-06-23 14:43:14)
aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)
Offline