AS sometimes happens, I have created what I would say is a hot mess in my htaccess file. I’ve got several problems, I know I’m internally looping on occasion, and I’m not great at this anyways. I’ve looked through dozens upon dozens of SO questions and tried tons of solutions. The end result is that I’m trying to piece together more than one separate solution to a multi-part problem and I’ve made a real mess. This is exclusively been my mission for days. I’m stuck. Bad.
- I want mydomain.com/handmade-jewelry to go to mydomain/handmade-jewelry/ (note slash)
- Then I also have .com/handmade-jewelry/some-piece going to jewelry-details.php?id=some-piece. That works, but it also needs a trailing slash.
- When I try to show a trailing slash on “/some-piece/”, it redirects out and hits a file not found.
Trust me. I know there’s got to be glaring flaws in my logic here, and I resisted asking this question since Saturday. I know this is super-oft asked. I wouldn’t be asking if I wasn’t dead stuck.
( 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]
Sorry again. I know for a lot of you, this kind of question gets redundant.
Try adding the following to your htaccess file in the root directory of your site