.htaccess - HTAccess Rewrite Rules with get parameters -


i building page should receive parameters determine content display. in order create better-looking urls, using htaccess allow urls appear following:

http://www.domain.com/elections/candidate-speech/candidate-name/

and redirect page

http://www.domain.com/elections/candidate-speech.php?name=candidate-name

i have done before , re-using rules wrote different page similar desired structure. rule using is:

rewriteengine on    # turn on rewriting engine  rewriterule  ^candidate-speech/([a-za-z0-9-]+)/?$    candidate-speech.php?name=$1 

if directly load intended url (http://www.domain.com/elections/candidate-speech.php?name=candidate-name) candidate's name, page displayed intended. when attempt use shortened version, however, correct page nothing provided in $_get.

the .htaccess file stored in elections directory, relevant .php file, same setup used in past rule successful. new htaccess, why falling on previous success it. have restarted server, cleared cache, et al. no avail. doing wrong?

have way:

options -multiviews rewriteengine on rewritebase /elections/  rewriterule ^candidate-speech/([\w-]+)/?$ candidate-speech.php?name=$1 [l,qsa,nc] 

disabling multiviews option important here since .php file name same starting component candidate-speech/.

option multiviews (see http://httpd.apache.org/docs/2.4/content-negotiation.html) used apache's content negotiation module runs before mod_rewrite , makes apache server match extensions of files. if /file url apache serve /file.html.


Comments