I have an htaccess file that is doing a lot, and some things aren't working well. I believe there's just too many different tasks going on causing conflicts.
Here's what I need it to do.
1. Make sure www. is present on the base URL
2. Add a trailing slash to the address, even when ending in .php, (not necessary for .html but I don't think really matters)
3. Restrict access to the /admin directory unless it's coming from a specific IP, otherwise redirect to the index.
The admin directory is tricky because the system I'm using does some rewrites of it's own, i.e. www.website.com/admin -> www.website.com/index.php/admin/
but you can also get to other parts of the admin by using www.website.com/index.php/admin/module/.
So I'm thinking I might need to use some type of query instead of URI.
Here's what I have so far:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.website.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9_\-]{1,5}|/)$
RewriteRule ^(.*)$ http://www.website.com/$1/ [R=301,L]
rewritecond %{http_host} ^website.com [nc]
rewriterule ^(.*)$ http://www.website.com/$1/ [r=301,nc]
RewriteCond %{REQUEST_URI} !^/robots\.txt$
#RewriteCond %{HTTP_HOST} !^www\.website\.com$ [NC]
#RewriteRule ^(.*)$ http://www.website.com/$1/ [R=301,L]
RewriteCond %{REMOTE_HOST} !^123\.456\.789\.111
RewriteCond %{REMOTE_HOST} !^456\.789\.111\.222
RewriteCond %{REQUEST_URI} ^/admin/$
RewriteRule (.*)$ http://www.website.com/ [R=302,L]
Any help getting this all working would be great. I've been trying to clean it up but nothing it really working fully.
Thank you!!