Open GoogleCodeExporter opened 9 years ago
Also this rule:
RewriteRule ^/wiki(.*)$ http://wiki.opencaching.pl$1 [R,L]
I believe should be preceeded by this condition, since it is node specific.
RewriteCond %{HTTP_HOST} \.pl$ [NC]
Original comment by andrixnet
on 10 Apr 2014 at 12:28
Regarding c#1 the rule could be changed to something using %{HTTP_HOST} such
that it makes URLs /wiki* -> wiki.opencaching.XX*
if convenient for NL as well to use such semantics.
I have no objection from RO. (our wiki is still empty, but will grow).
Original comment by andrixnet
on 10 Apr 2014 at 12:33
This file seems to be per installation dependent at this time. I have just
encountered some problems with OCNL as Harrie told me.
I will analyze this file further and propose fizes to make it installation
independent, but I one thing I know for sure is that they WILL REQUIRE some
configuration changes to the webserver, for each installation.
Original comment by andrixnet
on 7 Jun 2014 at 11:46
Original comment by wloczynutka
on 9 Jul 2014 at 5:56
For system administrator's consideration, I will discuss each section in
sitewide .htaccess :
There are several per node rewrite rules that can and should be optimized on
the following considerations:
a) no need to include per node specific items in repository rewrite rules
b) wasted CPU time on checking rules only valid for other nodes then your own
c) more flexibility
==============================================================
Line 3:
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [NE,R=301,L]
This rule rewrites www.opencaching.XX to opencaching.XX. It is node specific,
as in each sysadmin decides if his site should default with www prefix or not.
Also, this rule would not apply to any site without the www prefix.
Solution:
In webserver config, after the main site's configuration, add a <VirtualHost>
section as follows:
# main site
<VirtualHost *:80>
ServerName opencaching.XX
[...]
</VirtualHost>
# redirections
<VirtualHost *:80>
ServerName www.opencaching.XX
ServerAlias YYY.opencaching.XX
Redirect permanent / http://opencaching.XX/
# ^^^^^^^^^^^^^^ points to ServerName of main site.
</VirtualHost>
Chang the ServerName, ServerAlias and Redirect parameters accordingly.
==============================================================
Line 8:
RewriteRule ^search\.(gpx|kml|loc|ov2|ovl|txt|wpt|uam|xml|zip|ggz)$
search.php?%{QUERY_STRING} [NC]
RewriteRule ^ocpl(\d+)\.(gpx|kml|loc|ov2|ovl|txt|wpt|uam|xml|zip|ggz)$
search.php?queryid=$1&output=$2&%{QUERY_STRING} [NC]
RewriteRule ^ocplgpx(\d+)\.(gpx)$
search.php?queryid=$1&output=gpxgc&%{QUERY_STRING} [NC]
No change would be necessary.
==============================================================
Line 11:
RewriteRule ^/wiki(.*)$ http://wiki.opencaching.pl$1 [R,L]
This rule is explicit for Poland at this time.
It also should be moved to main webserver config, that is into <VirtualHost>,
like this:
RedirectMatch permanent /wiki(.*)$ http://wiki.opencaching.XX/
# ^^^^^^^^^^^^^^^^^^^^^^^^^^ URL of your Wiki
This allows redirection of all wiki URLs to the wiki site without requiring
it's name to explicitely start with "wiki"
==============================================================
Line 11:
RewriteRule ^/statpics/([0-9]+)\.jpg$ ocstats.php?userid=$1 [R,L]
No change would be necessary.
==============================================================
Line 14:
RewriteCond %{HTTP_HOST} \.nl$ [NC]
RewriteRule ^(OB[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z])$ viewcache.php?wp=$1
[R=301,L,NC]
RewriteCond %{HTTP_HOST} \.pl$ [NC]
RewriteRule ^(OP[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z])$ viewcache.php?wp=$1
[R=301,L,NC]
RewriteCond %{HTTP_HOST} \.ro$ [NC]
RewriteRule ^(OR[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z])$ viewcache.php?wp=$1
[R=301,L,NC]
These rules do needless matching, even several times on some nodes. They could
be merged into a single rule.
Each node defines a 2 letter prefix for cache code, followed by 4 alphanumeric
characters to identify the cache.
Currently there are 3 nodes, but a good code must allow an arbitrary set of
nodes.
Limitations:
2 letter cache prefix limits total number of independent nodes to 676. More
then enough, given the fact that there are 195 countries (Taiwan isn't
recognized as such).
If prefix were to be limited to O_, then there would only be 26 possible nodes,
which is way too few.
4 character alphanumeric identifier limits total number of caches per node to
1,679,616, which is quite a big number for a single country, considering that
Groundspeak boasts with about 2,525,843 worldwide.
Opencaching website also lacks human readable URLs (which are also preferred by
Google and other search engines).
With the above considerations, I suggest the following rule:
#RewriteCond %{REQUEST_FILENAME} !-f # exclude existing files
#RewriteCond %{REQUEST_FILENAME} !-d # exclude existing directories
RewriteRule ^([A-Z]{2}[0-9A-Z]{4})(__.*)?$ viewcache.php?wp=$1 [R=301,L,NC]
# ^^^ ^^^^^^ ^^^\- human readable URL, that is cache name
in URL (optional)
# | \-------------- 4 character alphanumeric identifier
# \----------------------- 2 letter prefix
This rule is checked only once, it is valid for each node and also allows URLs
like this:
http://opencaching.pl/OP1234__your-cache-name
Of course, making human readable URLs available throughout the site requires
other changes in the code, but this is the foundation for it.
At this time there is no file to match this rule, but there are 3 directories:
/graphs, /images, /mobile are existing directories, and by this rule would also
become forbidden cache names.
Only asking /graphs or /images would result in returning the directory index of
these, so it is safe to rewrite these URL's
Asking for /mobile results in an incomplete and non-functional mobile version
of the site.
Thus "MOBILE"
To safely exclude this one should add in main site <VirtualHost> the following:
Redirect permanent /mobile http://mobile.opencaching.XX/
Original comment by andrixnet
on 10 Nov 2014 at 8:10
Attached you will find the proposed .htaccess file.
Original comment by andrixnet
on 10 Nov 2014 at 8:14
Attachments:
Replace in my instructions above:
Redirect permanent /mobile http://mobile.opencaching.XX/
with
RedirectMatch permanent /mobile(.*)$ http://m.opencaching.XX/
Original comment by andrixnet
on 10 Nov 2014 at 8:25
Another issue which is per node and does NOT belong in .htaccess but server
config is the setting of PHP limits.
By default PHP allows uploads with a maximum of 2M per file, maximum 20 files
and maximum of submitted data (all files and variables) of 8M.
Since uploads at OPENCACHING-PL application level define 5M per file (MP3
uploads), PHP configuration however is more strict and has to be reconfigured.
AFAIK OPENCACHING-PL application currently uploads only a single file.
Consequently, in main site <VirtualHost> you should include this in the
directory definition for your DocumentRoot:
# Total request size
php_admin_value post_max_size 10M
# Largest file upload
php_admin_value upload_max_filesize 5M
upload_max_filesize must be the same or larger then the largest filesize limit
in your settings.inc.php
Original comment by andrixnet
on 10 Nov 2014 at 8:43
Status:
OCRO: all specific configurations moved to server config
.htaccess in sync with repository
ready to accept proposed version of .htaccess
OCPL: please consider these modifications and implement them in server config
OCNL: please consider these modifications and implement them in server config
When all nodes have implemented changes in server config, new version of
.htaccess can be deployed via SVN.
Original comment by andrixnet
on 10 Nov 2014 at 9:26
Original issue reported on code.google.com by
andrixnet
on 10 Apr 2014 at 12:25