Thanks for posting, but your comments are a little odd.
They're generally odd - well, pedantic. I seek perfection and comment to help others learn.
(1) As for using "RewriteBase /" then all I've done is follow this:
http://www.rackspace.com/knowledge_c...ing_on_my_site. If they're wrong, then surely it's not a big deal anyway is it? Are they wrong about their own server?
Rackspace's problem as that's what Apache says about RewriteBase. Please ask Rackspace why they'd recommend something like that.
(2) The trailing slash helps prevent duplicate content for SEO (
http://www.seroundtable.com/archives/022083.html). As you control all links on your site, then you just ensure all links include the trailing slash, which means htaccess rarely needs to redirect it. If any come externally then .htaccess does the redirect, which helps prevent duplicate content. Try going to apple.com/ipad and you'll see they do exactly this.
apple.com/ipad? Where's the trailing /?
If you're saying that my code will add a trailing slash to every url, and it's only needed for a directory, then that is exactly the kind of thing I need help on. That said, all links will be in the format domain.com/page/var/var2/var3/ etc. anyway.
The domain.com/page/var/var2/var3/ indicates a mod_rewrite is supposed to grab those variables and redirect to a handler file. The series of "pseudo directories," though, tell the visitors' browsers to request support files from different level directories which causes a problem for relative links. If you were to use the above where page={serveable script}, then you must have Options MultiViews enabled - I find MultiViews to be a major PITA as you must understand that the servable script does not require the file extension to be served by Apache so you must carefully watch your choice of file/directory names.
(3) HTTPS, yes there is a need to use all-https on the site. The site involves content where its security is paramount. Many sites are going https-only these days, such as odesk.com. By going to odesk.com you will see the https redirect.
That's a choice for you to make. The simple fact that someone else is doing it isn't sufficient reason for me to believe that everyone should be doing it. HTTPS adds load on the server and increases bandwidth - but those penalties won't hurt a low traffic site, so, if you have the Secure Server certificate and desire to go HTTPS, then by all means, do it.
(4) I ask for help improving the code, and you seem to spend ages commenting on it, but haven't offered a better way to write the code. I understand nobody has to help on a forum, and I respect that, but you did take the time to comment.
Other than the recommended deletions (the "why in the worlds"), the only change I recommended was removing the ENV: from the Apache variable %{HTTPS}, altering the single character requirement to making it optional and using %{REQUEST_URI} instead of $1. As requested ...
(5) You say, "I'll let you place that in the mess above". Well, obviously I can't, that's why I was asking. Thanks for providing the line of code though, I just need to know if it needs to be merged in with other parts of the code. Again,, you say its a mess, so that is why I'm asking for help re-writing it.
That was a challenge for you ... to see whether you understand mod_rewrite or just want someone to script for you. Anyway, I'd put it anywhere (my preference is immediately before) the "send everything to index.php" block.
(6) Also, you've highlighted ENV and [NC] in this:
Code:
# the next line may be specific to my server
RewriteCond %{ENV:HTTPS} !on [NC]
...is there a problem, as again that's come from my server owners specifically (
http://www.rackspace.com/knowledge_c...on_my_PHP_site)?
I can't comment about Rackspace on this one either. {HTTPS} is an Apache variable while you must set the environmental variable to be able to use {ENV:HTTPS} - unless they perform that setting with non-standard coding. I can't imagine why they'd do that either so ... well, ask Rackspace why they're using an environmental variable setting, how it gets set and why they're not simply using {HTTPS}.
I would still appreciate help from anyone who could spare the time. I can't / won't change the things dklynn has commented on though as they are important, but I do need help improving and condensing the code.
That's your choice, sir.
Thanks again for taking the time though dklynn. It has at least made me keen to get additional help and make additional checks before I sign this off.
Bookmarks