Apache Rewrite Rules


/ Published in: Apache
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <IfModule rewrite_module>
  2. Options +FollowSymLinks
  3. RewriteEngine ON
  4. RewriteLog /Developer/Servers/apache2/logs/mod_rewrite.log
  5. RewriteLogLevel 2
  6.  
  7. # BlogCFC URL Rewrite Rules
  8. #RewriteRule ^/([A-Za-z0-9-]+)/projects/blog/([\w]+)/index.cfm/(.*)$ /$1/projects/blog/$2/index.cfm?blogParams=$3 [PT,L]
  9. # Blog URL Rewrite Rules
  10. RewriteRule ^/([A-Za-z0-9-]+)/projects/blog/([\w]+)/index.cfm/(.*)$ /$1/projects/blog/$2/index.cfm?blog_param=$3 [R]
  11.  
  12. RewriteCond %{QUERY_STRING} ^blog_alias=([\w]+)(.*)$ [NC]
  13. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/index\.cfm /$1/projects/$2/%1/?%2 [R]
  14. # If trailing slash is not provided...add trailing slash, and go to default site
  15. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)$ /$1/projects/$2/default/ [R]
  16. # If site is not provided...go to default site
  17. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/$ /$1/projects/$2/default/ [R]
  18. # If site is provided, but trailing slash is not provided...add trailing slash, and go to site
  19. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/([\w]+)$ /$1/projects/$2/$3/ [R]
  20. # If loading an include...pass on through
  21. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/([\w]+)/includes/(.*)$ /$1/projects/$2/includes/$4 [QSA,PT,L]
  22. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/([\w]+)/admin/(.*)$ /$1/projects/$2/admin/$4?blog_alias=$3 [QSA,PT,L]
  23. # site is provided, and all is good...pass on through
  24. #RewriteRule ^/([A-Za-z0-9-]+)/(blog[0-9]*)/([\w]+)/(.*)$ /$1/$2/index.cfm?blog_alias=$3 [QSA,PT,L]
  25. RewriteRule ^/([A-Za-z0-9-]+)/projects/(blog[0-9]*)/([\w]+)/(.*)$ /$1/projects/$2/$4?blog_alias=$3 [QSA,PT,L]
  26.  
  27. # CMS URL Rewrite Rules
  28. RewriteCond %{QUERY_STRING} ^site_alias=([\w]+)(.*)$ [NC]
  29. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)/index\.cfm /$1/projects/$2/%1/?%2 [R]
  30. # If trailing slash is not provided...add trailing slash, and go to default site
  31. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)$ /$1/projects/$2/default/ [R]
  32. # If site is not provided...go to default site
  33. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)/$ /$1/projects/$2/default/ [R]
  34. # If site is provided, but trailing slash is not provided...add trailing slash, and go to site
  35. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)/([\w]+)$ /$1/projects/$2/$3/ [R]
  36. # If loading an asset...pass on through
  37. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)/([\w]+)/assets/(.*)$ /$1/projects/$2/assets/$4 [QSA,PT,L]
  38. # site is provided, and all is good...pass on through
  39. RewriteRule ^/([A-Za-z0-9-]+)/projects/(cms[0-9]*)/([\w]+)/(.*)$ /$1/projects/$2/index.cfm?site_alias=$3 [QSA,PT,L]
  40. </IfModule>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.