.htaccess - Htacces mod_rewrite sub directory -
i'm having problem .htaccess mod_rewrite. i've made simple custom cms , i've put in sub directory of domain; http://www.example.com/cms
i've got following situations:
cms/index.php?page=modules/pages/index.php convert to cms/modules/pages/index
and cms/index.php?page=modules/pages/edit.php?id=1 convert to cms/modules/pages/edit/1
i've got working subdomain, when use example.com/cms doesn't anything
i've made .htaccess couldn't working...
rewriteengine on options +followsymlinks rewritebase / rewritecond %{request_filename} -f [nc,or] rewritecond %{request_filename} -d [nc] rewriterule ^(.*?)$ $1 [l] rewriterule ^/cms/([^/]*)/$ cms/index.php?page=$1 [l,qsa] rewriterule ^/cms/([^/]*)$ /cms/index.php?page=$1 [l,qsa] rewriterule ^/cms/pages/([^/]*)/$ /cms/index.php?page=pages/$1 [l,qsa] rewriterule ^/cms/pages/([^/]*)$ /cms/index.php?page=pages/$1 [l,qsa] rewriterule ^/cms/modules/([^/]*)/([^/]*)/$ /cms/index.php?page=modules/$1/$2 [l,qsa] rewriterule ^/cms/modules/([^/]*)/([^/]*)$ /cms/index.php?page=modules/$1/$2 [l,qsa] rewriterule ^/cms/modules/([^/]*)/([^/]*)/([^/]*)$ /cms/index.php?page=modules/$1/$2&id=$3 [l,qsa]
if in htaccess file, uri's have prefix removed (the leading slash), patterns won't match anything. either remove leading slash pattern or make optional (with ?
):
rewriterule ^/?cms/([^/]*)/$ cms/index.php?page=$1 [l,qsa] rewriterule ^/?cms/([^/]*)$ /cms/index.php?page=$1 [l,qsa] rewriterule ^/?cms/pages/([^/]*)/$ /cms/index.php?page=pages/$1 [l,qsa] rewriterule ^/?cms/pages/([^/]*)$ /cms/index.php?page=pages/$1 [l,qsa] rewriterule ^/?cms/modules/([^/]*)/([^/]*)/$ /cms/index.php?page=modules/$1/$2 [l,qsa] rewriterule ^/?cms/modules/([^/]*)/([^/]*)$ /cms/index.php?page=modules/$1/$2 [l,qsa] rewriterule ^/?cms/modules/([^/]*)/([^/]*)/([^/]*)$ /cms/index.php?page=modules/$1/$2&id=$3 [l,qsa]
additionally, first rule can simplified just:
rewritecond %{request_filename} -f [nc,or] rewritecond %{request_filename} -d [nc] rewriterule ^ - [l]
Comments
Post a Comment