php - Two-language site and showing variables by .htaccess -
i have such files: index.php
<?php echo $_request['cat_id']; echo "***"; echo $_request['page']; ?>
and .htaccess
<ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^ru/ index.php rewriterule ^ua/ index_ua.php rewriterule ^ru/(.*)/ index.php?cat_id=$1 rewriterule ^ua/(.*)/ index_ua.php?cat_id=$1 rewriterule ^ru/(.*)/([0-9]+)/ index.php?cat_id=$1&page=$2 rewriterule ^ua/(.*)/([0-9]+)/ index_ua.php?cat_id=$1&page=$2 rewriterule ^(.*)/ index.php?cat_id=$1 rewriterule ^(.+)/([0-9]+)/ index.php?cat_id=$1&page=$2 </ifmodule>
http://site2.com/ru/stranica/2/ shows:
index.php/stranica***2
http://site2.com/ru/stranica/ shows:
index.php/stranica***
http://site2.com/ru/ shows:
index.php***
why $_request['cat_id'] show index.php, instead stranica ? thanks!
it because regex using greedy .*
pattern , not using anchors needed.
you can use these rules:
<ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule ^ - [l] rewriterule ^ru/?$ index.php [l,qsa] rewriterule ^ua/?$ index_ua.php [l,qsa] rewriterule ^ru/([^/]+)/?$ index.php?cat_id=$1 [l,qsa] rewriterule ^ua/([^/]+)/?$ index_ua.php?cat_id=$1 [l,qsa] rewriterule ^ru/([^/]+)/([0-9]+)/?$ index.php?cat_id=$1&page=$2 [l,qsa] rewriterule ^ua/([^/]+)/([0-9]+)/?$ index_ua.php?cat_id=$1&page=$2 [l,qsa] rewriterule ^([^/]+)/([0-9]+)/?$ index.php?cat_id=$1&page=$2 [l,qsa] rewriterule ^([^/]+)/?$ index.php?cat_id=$1 [l,qsa] </ifmodule>
Comments
Post a Comment