.htaccess - Complex URL rewiting -


here trying achieve

www.example.com/category www.example.com/category/subcategory www.example.com/category/subcategory/product www.example.com/static-page (like /about-us, /contact, /our-services) 

(category, subcategory, products, static-pages etc dynamic text , there permalink foreach thing in database)

if see above requests, notice extending directory sturcutre 1 step each time when link clicked, e.g, first category, , when clicked on subcatogery, sent category/subcategory/ , product page

anybody can me how acheive this, have tried lot achieve in vain yet. using .htaccess

rewriterule c/(.*)/(.*)/ cat-details.php?permalink=$1&subcat=$2 rewriterule c/(.*)/(.*) cat-details.php?permalink=$1&subcat=$2  rewriterule news/(.*)/(.*)/ news-detail.php?news-id=$1&permalink=$2 rewriterule news/(.*)/(.*) news-detail.php?news-id=$1&permalink=$2  rewriterule d/(.*)/(.*)/(.*)/(.*)/ download-detail.php?download-id=$1category=$2&subcategory=$3&permalink=$4 rewriterule d/(.*)/(.*)/(.*)/(.*) download-detail.php?download-id=$1category=$2&subcategory=$3&permalink=$4  

as can see have add c/, news/, d/ etc each link, trying rid of , want make links pretty whitout proceeding c/, news/, d/ etc

any or idea please.

about way you're going able in apache proper, provide info on urls map scripts. apache lets via rewritemap directive, won't work in .htaccess files. without it, , without news/ or c/, apache doesn't have enough info route urls properly.

what do, rewrite every url doesn't refer existing file, script knows scripts run in response. "router" or "front controller" script, call it. this:

rewritecond %{request_uri} !-f rewritecond %{request_uri} !-d rewriterule (.*)   router.php?path=$1  [qsa] 

and in script, examine $_get['path'], decide script should handle request, , load/include/require it.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -