- adding tailing slash to Mod_rewrite and redirecting non-trailing slash in virtual dir
- ( rewrite all www and non-www requests to https:// ...works fine)
- RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
- RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
- RewriteCond %{HTTPS} !=on
- RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
- RewriteCond %{SERVER_PORT} ^80$
- RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
- (redirecting to the page with all the jewelry)
- RewriteRule ^handmade-jewelry/$ jewelry-inventory-page.php [L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- (following was a failed attempt.)
- # RewriteCond %{REQUEST_URI} !rock-jewelry/(.*)/$
- (following works with no trailing slash, which is needed)
- RewriteRule ^handmade-jewelry/(.*)$ jewelry-details.php?s=$1 [L]
- (if I turn this on, it goes to a 404 looking for "handmade-jewelry/this-piece/index.php?s=thispiece/etc...")
- # RewriteRule ^handmade-jewelry/(.*)?/$ jewelry-details.php?s=$1 [L]
- RewriteEngine on
- RewriteBase /
- #( rewrite all www and non-www requests to https:// ...works fine)
- RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
- RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
- RewriteCond %{HTTPS} !=on
- RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
- #I believe this is redundant because of the previous rule
- RewriteCond %{SERVER_PORT} ^80$
- RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
- #if existing file or directory
- RewriteCond %{REQUEST_FILENAME} -f [OR]
- RewriteCond %{REQUEST_FILENAME} -d
- #do nothing
- RewriteRule ^ - [L]
- #if it does not end with a slash e.g. handmade-jewelry, redirect to with slash
- RewriteRule ^([-a-zA-Z0-9]+)$ /$1/ [L,R=301]
- #if it does not end with a slash e.g. handmade-jewelry/some-piece, add the slash
- RewriteRule ^([-a-zA-Z0-9]+/[-a-zA-Z0-9]+)$ /$1/ [L,R=301]
- #(redirecting to the page with all the jewelry)
- RewriteRule ^handmade-jewelry/$ jewelry-inventory-page.php [L,NC]
- RewriteRule ^handmade-jewelry/([-a-zA-Z0-9]+)/$ jewelry-details.php?s=$1 [L,NC]