Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 1.99 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. adding tailing slash to Mod_rewrite and redirecting non-trailing slash in virtual dir
  2. ( rewrite all www and non-www requests to https:// ...works fine)
  3. RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
  4. RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
  5. RewriteCond %{HTTPS} !=on
  6. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  7. RewriteCond %{SERVER_PORT} ^80$
  8. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  9.  
  10. (redirecting to the page with all the jewelry)
  11. RewriteRule ^handmade-jewelry/$ jewelry-inventory-page.php [L]
  12.  
  13. RewriteCond %{REQUEST_FILENAME} !-f
  14. RewriteCond %{REQUEST_FILENAME} !-d
  15. (following was a failed attempt.)
  16. # RewriteCond %{REQUEST_URI} !rock-jewelry/(.*)/$
  17. (following works with no trailing slash, which is needed)
  18. RewriteRule ^handmade-jewelry/(.*)$ jewelry-details.php?s=$1 [L]
  19. (if I turn this on, it goes to a 404 looking for "handmade-jewelry/this-piece/index.php?s=thispiece/etc...")
  20. # RewriteRule ^handmade-jewelry/(.*)?/$ jewelry-details.php?s=$1 [L]
  21.        
  22. RewriteEngine on
  23. RewriteBase /
  24.  
  25. #( rewrite all www and non-www requests to https:// ...works fine)
  26. RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
  27. RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
  28. RewriteCond %{HTTPS} !=on
  29. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  30.  
  31. #I believe this is redundant because of the previous rule
  32. RewriteCond %{SERVER_PORT} ^80$
  33. RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  34.  
  35. #if existing file or directory
  36. RewriteCond %{REQUEST_FILENAME} -f [OR]
  37. RewriteCond %{REQUEST_FILENAME} -d
  38. #do nothing
  39. RewriteRule ^ - [L]
  40.  
  41.  
  42. #if it does not end with a slash e.g. handmade-jewelry, redirect to with slash
  43. RewriteRule ^([-a-zA-Z0-9]+)$ /$1/ [L,R=301]
  44.  
  45. #if it does not end with a slash e.g. handmade-jewelry/some-piece, add the slash
  46. RewriteRule ^([-a-zA-Z0-9]+/[-a-zA-Z0-9]+)$ /$1/ [L,R=301]
  47.  
  48. #(redirecting to the page with all the jewelry)
  49. RewriteRule ^handmade-jewelry/$ jewelry-inventory-page.php [L,NC]
  50.  
  51. RewriteRule ^handmade-jewelry/([-a-zA-Z0-9]+)/$ jewelry-details.php?s=$1 [L,NC]