I've cut and pasted so many .htaccess files my fingers are turning blue. The last few solutions I tried, redirected all of my links to index.php and I don’t want that. Since I don’t really understand what I’m doing, I can’t figure out how to fix this. I’m a web designer, not a programmer, but I prefer the clean URLs. So, I need to do the following:
- Redirect www and http to https;
- Make all URLs extensionless, without trailing slash;
- Redirect each .php and trailing slash to the clean URL--I have multiple PHP files, so I need a wildcard solution, not one for a specific page;
- I also display data pulled from a database on two different pages (view.php and edit.php). I'd like the URL to look like view/1 and edit/1 instead of view.php?id=1 and edit.php?id=1.
My current .htaccess looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
My host provides free SSL and told me to place the above code to redirect www and http to https, so I think I’m all set with #1. I now need to figure out how to implement/integrate #2, #3 and #4.
I have tried solutions at How can I make all my urls extensionless, without trailing slash. And redirect the .php and trailing slash to none? and How to redirect all my urls with no extension to end with .php and many others, but nothing gives me exactly what I need.