I dream of a drush command that would backup and patch .htaccess (using the drupal core pretty urls at the end as an anchor to insert before)
And also for those that have modified their .htaccess prior to boost installation we should release just the boost rules in a file - not the whole .htaccess. I propose this to be the only form of distribution of the boost rewrite rules. Should be mentioned in .htaccess.
With a warning in INSTALL.txt for those who install to resolve any possible conflicts between pre-boost manual rules and boost rules...
If anyone knows of an include statement in .htaccess files let me know - thus it will be a matter of just inserting one line in the .htaccess that references a file in the boost module dir...
What do you think? Is a patch welcome?
PS I notriced that the (6.x.dev) boosted1.txt file is a little out of date with the 6.10 core .htaccess - which combined with my manual customizations made the idea appear.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | boost-428942.patch | 4.61 KB | mikeytown2 |
| #33 | boost-428942.1.patch | 2.68 KB | mikeytown2 |
| #32 | boost-428942.patch | 3.19 KB | mikeytown2 |
| #30 | boost.module.patch | 1.63 KB | mikeytown2 |
| #28 | htaccess_generate.php.txt | 3.53 KB | mikeytown2 |
Comments
Comment #1
mikeytown2 commentedis there an example of this being done out there?
Comment #2
rsvelko commentedkeeping it simple: for starters - lets just gather opinions: would you like a change in boost install process like that above?
The drush part is the last thing to be done.
@mikeytown2: you mean me attaching a patch ? this evening will try
Comment #3
mikeytown2 commentednot adding a patch just yet; wondering if there is any example of a module checking & editing the root .htaccess file, and if that would be bad for security.
Comment #4
rsvelko commentedthought 10 mins about it : lets keep it simple :
- forget about auto-patching .htaccess via drush (at least until the install process for modules becomes more advanced - with custom pre/post install scripts and user prompts ...)
- leave only boost specific rules in the what are now boosted1.txt and the boosted2 (patch underway)
- patch install and/or readme to give proper info ...
seems trivial and a better way to install boost - are we/you into it?
Comment #5
mikeytown2 commentedyour proposal, short and simple: boosted(1/2).txt only has the
in it. I think we could do something like that; but having the full .htaccess file is kinda nice, so we could make the default.txt file have a
#Paste Boost Changes Heresection. Update readme file to reflect changes. Is this what your thinking?Comment #6
rsvelko commentedYES, with a little clarification:
- .htaccess is nice to have but it changes slightly with every new drupal core release - that is the main reason behind me dropping it
- maybe it will be easier and enough if we just say in the readme(or install):
"In the main .htaccess of your Drupal folder find the lines like these at the end and paste the contents of boosted1.txt BEFORE them :
[.htaccess file ]
...
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $
[end of file]
The result should look like :
[.htaccess file ]
...
#BOOST START
....
#BOOST END
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $
[end of file]
"
Seems ok to me. Maybe finding a shorter way to explain it will be good but not so important.
Comment #7
rsvelko commentedactually I have a smarter idea now:
why don't we just automate the
#BOOST START
....
#BOOST END
rules creation process via php(or js) and make these rules copy-pastable from the boost UI to the .htaccess file with checkboxes which rule set does the user want to see .
This makes sense cause the rules have 2-3 variants (boosted1.txt and boosted2.txt) and it would make things more user friendly.
Comment #8
mikeytown2 commentedHere's a patch with the above changes (excluding change .htaccess via php) as well as these changes
http://drupal.org/node/204832#comment-1504968
This patch does not include replace $1 with %{REQUEST_URI} from that thread, just the simple changes.
___
Comment #9
mikeytown2 commentedComment #10
mikeytown2 commentedIn terms of using php to modify the .htaccess file, Wordpress modifies the .htaccess file, so it is doable http://codex.wordpress.org/Using_Permalinks#Using_.22Pretty.22_permalinks. I'm thinking boost stores a md5 of the text in between #BOOST START & #BOOST END in the db. Use the update.php mechanism when a change to the Boosts .htaccess rules are needed.
Or use something like this
http://drupal.org/project/patchdoq
Comment #11
patataur commentedFWIW, i had no problem in adding the required lines in my htaccess but i believe for boost to have a wider implementation, it would require "automatic" htaccess modifications (many users just won't edit their htaccess i believe).
But, i think it is not a priority. First, a stable release. Then an easier installation of the module, rather than the reverse.
Comment #12
rsvelko commentedLets keep it simple and safe - no modification of .htaccess via php .
Just creation of boost rules in the UI of boost in a fieldgroup and requiring the user to copy paste them...
Comment #13
mikeytown2 commentedI like the idea of the rules being inside the performance page, ready to be copied. Need to write the code for that...
Comment #14
mikeytown2 commentedI was thinking the easiest way to make sure people install the rule set correctly is to read the .htaccess file and throw a warning on the status page if the boost rules are not in there. This would check against the generated file, make sure they matched & is placed in the right spot (above index.php rule, below rewrite base).
Comment #15
mikeytown2 commentedCommitted the ideas from the top of this thread. Still open, since there are multiple issues in this one.
Comment #16
mikeytown2 commentedComment #17
rsvelko commentedlooked into the commits - very pleased.
What is left now is
1. the php code that will generate the rules in the UI to be pasted. (using a template file)
2. the code that will check the .htaccess file for the boost rules. Either checking strictly for the whole bunch of boost rules or just for the begin and end "# BOOST START" markers
Right?
Comment #18
mikeytown2 commentedOdds are a template file is not needed; we need to make a function that generates the code, with most of the code being hard coded in. For the rules checking it would make sure the rules where put in the right spot (below
# RewriteBase /and above# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.), and that there are at least 4RewriteRule ^(.*)$inside the Boost Start/End code block. On the status page, throw notices if the rules checking failed, linking to the handbook or something like that #443658: Boost Handbook Page(s). For the generation it should generate it for SERVER_NAME or HTTP_HOST and Normal or Subdir; only boost code, full .htaccess, unmodified .htaccess.Comment #19
rsvelko commented1. OK, please attach a text file with examples of all possible rules. I will take it and create the generating function. I leave the UI stuff to you (the page from which the user will paste the code).
2. I will make also the function that checks the .htaccess file for boost rules - you will take it and finish it to output status messages...
OK?
Comment #20
mikeytown2 commentedHere are the 2 rules, the Gzip part has slightly changed based off this code
http://drupal.org/node/101227#comment-1597328
The bug doesn't effect html files.
Here are a list of things that should be changeable
cache/OR User Defined/DRUPAL-SUBDIROR $base_path OR User Definedgz/OR User Defined%{DOCUMENT_ROOT}ORgetcwd()OR User Defined%{HTTP_HOST}OR%{SERVER_NAME}OR User DefinedI don't have a multi-site setup so I can not test for it; so for now do it for normal & subdir. Also be aware that #276495: Update for Rewrite Rules - Give Boost even bigger performance gain if it ever gets done will change the rules again & make them shorter; it would eliminate the gzip subdir bug most likely as well.
#101147: support subdirectory Drupal installations
Comment #21
rsvelko commentedOk, as soon as someone has some code - give it here so we can not do double work.
Comment #22
mikeytown2 commentedComment #23
mikeytown2 commentedComment #24
rsvelko commentedAttaching the prototype of the checker function.
Comment #25
rsvelko commentedas for the review of #22 and #23 - looks ok. Can you summarize all the modes of boost operation:
----- group one - possible site setups -----
- single/multisite
- root of vhost/subdir
- gzip/no gzip
- $base_url set/ not set
----- group two - possible input vars:
- cache/ OR User Defined
- /DRUPAL-SUBDIR OR $base_path OR User Defined
- gz/ OR User Defined
- %{DOCUMENT_ROOT} OR getcwd() OR User Defined
- %{HTTP_HOST} OR %{SERVER_NAME} OR User Defined
Which of the possible permutations we are going to do? I am putting it all in one post here. Is $base_url set up in settings.php still a requirement?
Comment #26
mikeytown2 commentedThe last patch #367081: System-Ran Cron, Not User made it so cron will still work even if $base_url is not set; but it's not %100, which is why $base_url should be set.
Refactored the rules so it includes #276495: Update for Rewrite Rules - Give Boost even bigger performance gain and so normal/subdir look almost identical. Auto configures $base_path as well. Usage is fairly straight forward IMO, unless your not following the defaults or have some funky server settings, it should just work.
Comment #27
mikeytown2 commentedNewest one based off of this revelation.
Comment #28
mikeytown2 commentedfurther refinements & support for index url variables
Comment #29
mikeytown2 commentedCame up with another idea to make the htaccess file smaller. Make query & normal files look the same; get rid of index. Inside boost_init() change
to this
It works. Thoughts??? Unless there are some good reasons to not do this, I will commit this as it makes the code simpler (boost block works with queries now).
Comment #30
mikeytown2 commentedHere's a patch with more refinements.
Comment #31
mikeytown2 commentedcommitted code from #29, along with corresponding changes to htaccess
Comment #32
mikeytown2 commentedPatch generates htaccess rules inside settings page now.
Comment #33
mikeytown2 commentedpatch checks for rewrite rules, makes sure there are 4 of these strings in your .htaccess file.
Comment #34
mikeytown2 commentedcommitted 32, 33
Comment #35
mikeytown2 commentedNeed to use AHAH and add in some selection tools so user can generate different .htaccess code from interface.
Comment #36
mikeytown2 commentedAllows for selection of rules; using -s instead of -f (checks that file size is greater then 0). Still does not use AHAH, any help with AHAH is greatly appreciated.
Comment #37
mikeytown2 commentedcommitted. Still looking for AHAH solution.
Comment #38
mikeytown2 commentedComment #39
mikeytown2 commentedComment #40
rsvelko commentedsome AHAH reference for newbies like me :
http://en.wikipedia.org/wiki/AHAH
http://randyfay.com/ahah
http://drupalsn.com/learn-drupal/drupal-tutorials/getting-going-ahah-and...
Comment #41
mikeytown2 commentedMarking this postponed until it's needed or someone submits a patch.
Comment #42
juan_g commentedMike wrote:
Yes, WP Super Cache (plugin for static file caching), the Boost equivalent for WordPress, automatically inserts mod_rewrite rules into the .htaccess file during installation.
Comment #43
mikeytown2 commentedClosing this since it is on its own tab now, thus AHAH is not needed.