mysql - How to control .htaccess with php or how to input php code inside .htaccess file -


i'm not in .htaccess, don't know how work, have site , site link that: mysite.com/pagee.php?menu_id=1 use .htaccess code:

<ifmodule mod_rewrite.c> rewriteengine on  # 1-level rewriterule ^home/{0,1}$  pagee.php?menu_id=1 [qsa,l]   </ifmodule> 

and work that: mysite.com/home/

but problem have lot of page like:

mysite.com/pagee.php?menu_id=2, mysite.com/pagee.php?menu_id=3, mysite.com/pagee.php?menu_id=4, mysite.com/pagee.php?menu_id=5, mysite.com/pagee.php?menu_id=6,

and pagee.php code is:

    <?php require_once('config2.php');  $menu_id = intval($_get['menu_id']);  $query = "select * menu `menu_id`=$menu_id"; $result = mysql_query($query);   while($row = mysql_fetch_assoc($result)) {      echo '<h1>'.$row['mname'].'</h1>';  }  ?> 

pagee.php work mysql

so how while code work inside .htaccess that:

    <ifmodule mod_rewrite.c> rewriteengine on  # 1-level <?php  $query = "select * menu `menu_id`=$menu_id"; $result = mysql_query($query);   while($row = mysql_fetch_assoc($result)) {     $menu_id=$row['menu_id'];     $linkname=$row['linkname'];       echo 'rewriterule ^'.$linkname.'/{0,1}$  pagee.php?menu_id='$menu_id' [qsa,l]';  } ?>   </ifmodule> 

php can not control .htaccess ok, can control write , rewrite .htaccess file, can figure don't think work. can try also,

made function , inside this:

function edit_hta() {      echo "<ifmodule mod_rewrite.c> \r\n \r\n rewriteengine on \r\n";      require('config2.php'); $getquery=mysql_query("select * menu order menu_id desc"); while($rows=mysql_fetch_assoc($getquery)){$menu_id=$rows['menu_id']; $linkname=$rows['linkname'];  echo "\r\n rewriterule ^".$linkname."/{0,1}$  pagee.php?menu_id=".$menu_id. "[qsa,l] \r\n"; }      echo "\r\n </ifmodule>";  } 

ok, make form, textarea , submit button

<form method="post" action="<?php echo $_server['php_self']; ?>">       <label>         <textarea name="edit_ht" cols="45" rows="5"><?php echo edit_hta(); ?></textarea>       </label>       <input name="submit" type="submit" value="edit" />     </form> 

than make php coding inside page:

$submit = $_post['submit'];  if ($submit) {  $edit_ht = file_put_contents('.htaccess', $_post['edit_ht']);  } 

i hope can well, major thing if have lot of pages inside sql database first have create can see inside sheet, of links showing inside textarea this:

<ifmodule mod_rewrite.c>     rewriteengine on   rewriterule ^asasasa/{0,1}$  pagee.php?menu_id=10[qsa,l]  rewriterule ^zxzxzx/{0,1}$  pagee.php?menu_id=9[qsa,l]  rewriterule ^movie/{0,1}$  pagee.php?menu_id=8[qsa,l]    rewriterule ^song/{0,1}$  pagee.php?menu_id=7[qsa,l]    rewriterule ^software/{0,1}$  pagee.php?menu_id=6[qsa,l]    rewriterule ^home/{0,1}$  pagee.php?menu_id=5[qsa,l]   </ifmodule> 

then hit edit button .htaccess file edit, , method can control .htaccess file. hope understand if don't please give me comment. thank you.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -