.htaccess url rewrite multiple directories to GET parameters -
ok have site want write rewrite rules for. don't have much experience rewrites.
my .htaccess in /foo/, not root. here's want
case 1: example.com/foo/bar/ --> example.com/foo/includes/page.php?school=bar&id= case 2: example.com/foo/bar/1 --> example.com/foo/includes/page.php?school=bar&id=1 here have
rewriteengine on rewriterule ^(bar|baz)/(.*)$ ./includes/pages.php?school=$1&id=$2 [nc,l] there 2 possible values school bar , baz. id can have number of values. above code works in case 2 doesn't work in case 1. seems externally redirect in case 1 different urls depending on if there trailing slash or not. no thought why. help appreciated.
you can set code in htaccess (in foo folder)
rewriteengine on rewritebase /foo/ rewriterule ^(bar|baz)/([0-9]*)$ includes/page.php?school=$1&id=$2 [nc,l] .htaccess mod-rewrite url-rewriting
No comments:
Post a Comment