
|
[dokuwiki]
||
[Date Prev]
[09-2007 Date Index]
[Date Next]
||
[Thread Prev]
[09-2007 Thread Index]
[Thread Next]
[dokuwiki] Re: dokuwiki htaccess rules in conflict with other domain rewrites?
- From: Ryan Jacobs <ryan.jake@xxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Tue, 11 Sep 2007 16:40:09 -0300
Hi again,
Yea, I think my issue was one of the following:
- Either apache can't work with two different rewrite bases in two
different .htaccess files in the same path at once, or,
- The domain-wide stuff (to canonicalize) has to come before any other
rewrites, and the lower-level path rewrites (ie. the Dokuwiki specific
stuff) were executing first. Perhaps this was conflicting somehow with
the root rewrites.
Either way, I figured I needed to just duplicate the domain-wide stuff
in my /dokuwiki/.htaccess (like you suggested) ... but this lead to
headaches (seemingly host-related), which I won't get into...
Anyway, to make a long story short, I just did the reverse and moved the
Dokuwiki stuff into the root /.htaccess and decided to make it the
one-and-only .htaccess for the domain:
## First do the global domain stuff
# Canonicalize the domain
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
## Now do the /dokuwiki Dokuwiki stuff. I just added "dokuwiki/"
## before each entry from the generic Dokuwiki example
RewriteRule ^dokuwiki/_media/(.*) dokuwiki/lib/exe/fetch.php?media=$1
[QSA,L]
RewriteRule ^dokuwiki/_detail/(.*) dokuwiki/lib/exe/detail.php?media=$1
[QSA,L]
RewriteRule ^dokuwiki/_export/([^/]+)/(.*)
dokuwiki/doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^dokuwiki/$ dokuwiki/doku.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^dokuwiki/(.*) dokuwiki/doku.php?id=$1
[QSA,L]
RewriteRule ^dokuwiki/index.php$ dokuwiki/doku.php
Maybe not the ideal solution, bit it all seems to be working.
Cheers!
Ryan
Markus Frosch wrote:
Hi Ryan
hm I missed this "merging" part of documentation...
All my experience with mod_rewrite shows me that local rules overwrites
the rules from parent directories.
Maybe this feature will be implemented in the future.
But you should not rely on this at the moment ;-)
Markus
Ryan Jacobs schrieb:
Hi Markus!
Thanks very much for the reply.
hummm, I'm getting conflicting info as I scour Google more and see this
reply. I think there is one fundamental htaccess rule/concept that is
alluding me (I hope this is not going to be embarrassing for me):
If you have a .htaccess file in a domain root, and then one in a
subdirectory, how are their rules merged/combined/ordered?
apache.org documentation seems to imply that they are combined such that
rules defined in parent dir .htaccess files can override rules in child
.htaccess files. It seems to say that the rules merge/combine AND cascade.
However, your post, my experience, and a couple other sites I've read
seem to imply that the lowest .htaccess file found is THE ONE AND ONLY
.htaccess file, and any that rules that exist in .htaccess files in
parent directories are just ignored completely.
Maybe the latter only applies for things like rewrites, but not for
other directives (like "options", etc.).
I hope I've been able to justify my confusion here... without
embarrassing myself too much (I though I had already wrapped my head
around the basics of apache rewrites and directives).
Thanks!
Ryan
Markus Frosch wrote:
Hello Ryan,
I'm not sure what your problem is with this rewrite issue...
It's just logical to replace any parent rewrite rules if local rules are
existing. Just imaging what happens if Apache "merges" these rules. It
would end up in a chaotic configuration...
You should be able to solve the problem by adding the following as one
of the first rules to Dokuwiki's .htaccess:
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^/dokuwiki(.*)$ http://mydomain.com/dokuwiki$1 [L,R=301]
What do you think? :-)
Markus Frosch
Ryan Jacobs schrieb:
Hello!
I really hope this is an appropriate place to ask this question, as I
think it might be more apache rewrite-specific that dokuwiki-specific,
but I'm just not sure, and am hoping someone out there may shed some
light on things. I've scoured Google, but have only found a couple cases
of similar problems, but no actual solutions...
Basically I have a dokuwiki install rooted in a subdirectory of my
domain (http://mydomain.com/dokuwiki), all of which is hosted on a
shared commercial host (not my own server). I have URL rewriting setup
using an .htaccess file in my /dokuwiki folder and the standard rewrite
rules for a dokuwiki install (found at
http://wiki.splitbrain.org/wiki:rewrite and using "RewriteBase
/dokuwiki").
My problem arises when I try to setup some other domain-wide rewrite
rules in another .htaccess file at the root of the domain
(http://mydomain.com/). These new rules function for any directory in my
domain EXCEPT my dokuwiki installation at /dokuwiki. For example I use
the following in the domain root .htaccess to remove the www from all
domain requests:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
A request to http://www.mydoman.com/somefolder/ redirects to
http://mydoman.com/somefolder/, but http://www.mydoman.com/dokuwiki/
DOES NOT redirect. However if I turn off Dokuwiki rewriting and remove
my /dokuwiki/.htaccess file, then http://www.mydoman.com/dokuwiki/ DOES
redirect to the non-www version.
I read that apache has to do some tricky things to manage paths when
processing per-directory .htaccess rules (hence the RewriteBase), so
maybe there is some conflict here? Or perhaps there is something in the
default Dokuwiki .htaccess rules that somehow conflicts with .htaccess
rules higher up in the tree (though I didn't think that was possible)?
Sorry again if this is very apache specific, but I have to start
somewhere, and am perhaps a bit over my head at the moment.
Thanks and cheers,
Ryan
Gruß
Markus Frosch
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist
|

|