mod rewrite - mod_rewrite style URL replacement in PHP -


i'm looking simple solution rewrite url in php. customer wants store them in database can't use mod_rewrite.

basically looking php solution make happen:

^/(.*).html ==> /page.$1.html 

such php code exists? thank in advance.

i'm not entirely sure mean example since create never-ending redirection loop.

^/(.*).html ==> /page.$1.html ==> /page.page.$1.html ==> /page.page.page.$1.html ==> etc. 

i'm assuming since said you're getting these rules database want take specific strings instead of (.*)

what want match whatever you're trying search $_server['request_uri'] variable , redirect using php. this:

foreach ($searches $string) {     if (preg_match("@^/$string\.html$@", $_server['request_uri'])) {         header("http/1.1 301 moved permanently");         header("location: http://www.yoursite.com/page.$string.html");     } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -