Hey guys, I'm really struggling to write htaccess rules for dynamic pages. I've like 20 pages to redirect and hoping for someone to help me write code. What I want to do is redirect www.sp-lawoffice.co.il/text.php?lang=heb&id=4 to http://www.sp-lawoffice.co.il/?page_id=205 Code (markup): and redirect, www.sp-lawoffice.co.il/text.php?lang=heb&id=6 to http://www.sp-lawoffice.co.il/?page_id=207 Code (markup): anybody know how to do it? I have like more than 20 pages to redirect. Any help will be appreciated. Thanks!
If you're just "hard coding" these specific links shouldn't it be something like ... redirect 301 <from url> <to url> that should be it. If these are just examples of dynamic links: I don't think it's possible. If it was remotely possible with htaccess page_id would have to exist in the "from" url . It looks like you need to make some changes to your site code.
and dynamic links can be redirected by htaccess but writing the rules will give you hard times.. better modify your text.php file to redirect to the new url by adding somewhere on top: if($_GET['id]==4) { header('Location: http://dsssssss'); exit; } elseif.... Code (markup):
take a read in here.. http://parmendra.wordpress.com/2009/07/10/capturing-variables-through-htaccess/
Yes, I know it's possible to capture variables with htaccess. Now give me an example with the links he provided? You can't because it's not possible like I said.
He's trying to get a page_id=205 out of "lang=heb&id=4" ? Unless he wants to convert his page_id=4 . I'm just saying what he gave us isn't much to work with.
from his examples i see the ids increment with 201 , so if thats true for all his links, whats the problem?
If you feel so strongly no problem exists then you should be willing to provide an example with what he provided. You can't. Which was my point the first time I answered his question and you basically came in and just re-iterated my answer.
I made my statement it is possible, because i saw the logic in the samples he gave that the IDs increment with 201. So, if thats true for all his links, here's the solution: RewriteEngine On RewriteCond %{QUERY_STRING} lang=heb&id=(.*) RewriteRule ^text\.php tmp.php?id=%1 tmp.php contents: <?php header('Location: http://www.sp-lawoffice.co.il/?page_id='.(201+$_GET['id'])); ?> Code (markup):
Good example. I didn't base my answer on an " if " . That's usually a waste of time and money, two things most people don't have these days. Good work though , thank you. I hope it helps the OP and you are correct.