.htaccess - A custom rewrite rule on a PHP micro MVC framework -


i using mvc micro framework , have following .htaccess rules:

options -multiviews options -indexes  rewriteengine on rewritecond %{request_filename} !-d  rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-l rewriterule ^(.+)$ index.php?url=$1 [qsa,l] 

this rewrites index.php?url=(e.g. user/register/)

in controller named "profile" have action "view" (that takes 2 args) means url be:

profile/view/arg1/arg2 

what trying hava more friendly url like:

profile/1/profile-name 

but when try following:

rewriterule ^profile/([0-9]+)/(.*)/?$ profile/view/$1/$2 [nc,l] 

it not working.

in other words trying rewrite original url remove "view" action visit url entering profile id (arg1) , name (arg2).

what doing not working because translating friendly url not index.php , since defined l rule, leave profile/view/1/test not exist, combine last rule reads:

rewriterule ^profile/([0-9]+)/(.*)/?$ profile/view/$1/$2 [nc] rewriterule ^(.+)$ index.php?url=$1 [qsa,l] 

and since first match transform url, passed second rule in correct format. alternatively write correct target:

rewriterule ^profile/([0-9]+)/(.*)/?$ index.php?url=profile/view/$1/$2 [nc,l] 

hope helped


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -