views:

298

answers:

5

I have a site [hosted on DreamHost], using WordPress for the main content, but Subversion repositories in http://mysite/svn .

My file layout is:

webroot/
  blog   # wordrpress files
  .htaccess

My SVN repositories lay outside the web root, but they are correctly mapped to /svn/repository URLs.

When I put the WordPress permalink rewrite rules in my .htaccess file, the blog pages and permalinks work great, but it breaks Subversion.

This is my .htaccess file with everything extraneous removed:

RewriteEngine On
RewriteBase /

# try 1                                                                                       
#RewriteCond %{REQUEST_URI} svn [NC]                                                          
#RewriteRule . - [PT,L]                                                                       

# try 2                                                                                       
#RewriteRule ^svn.*  -  [PT,L]                                                                

# try 3
#RewriteCond %{REQUEST_URI} !^svn 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . blog/index.php [L]

The very last line breaks Subversion. Clients errors are like this:

$ svn ls https://mysite/svn/myrepo/
svn: PROPFIND request failed on '/svn'
svn: PROPFIND of '/svn': 405 Method Not Allowed (https://mysite)

If I comment out that last line, RewriteRule . blog/index.php, Subversion works. But having WordPress handle the the nice permalink stuff doesn't.

I tried the three "ignore any URL starting with 'svn'" approaches I've commented out above, and none work-- they seem to not do ANYTHING. With or without the PT pass-through flag.

I have googled quite a bit and it seems others have been stumped with mod_rewrite and WebDAV (which Subversion uses) stepping on each other. I found an extremely similar abandoned SO question here too, but no working solutions. Any clues?

+2  A: 

Have you considered moving your Subversion repositories to a different subdomain? For example, http://svn.mysite.com/

This would be an easy way out.

I've spent many hours pulling my hair out over mod_rewrite...any time you can avoid that, it's a win.

Luke Francl
Thanks for the tip. I'm trying to avoid that because I want secure (HTTPS) subversion and I only want to buy and manage one SSL cert and static IP. I feel I *should* be able to do this with mod_rewrite?
Nathan
Good point. What about using Subversion over SSH instead?
Luke Francl
A: 

Try #3 looks good, have you tried there:

RewriteCond %{REQUEST_URI} !^svn.*
silk
Thanks for the suggestion, but that doesn't work either.I don't understand, because any of those 3 things *should* be keeping the blog/index.php RewriteRule from firing, right? And if I comment out the index.php RewriteRule, it works fine...
Nathan
+4  A: 

How about

RewriteCond %{REQUEST_URI} !^/svn.*

?

Pekka
In particular, `%{REQUEST_URI}` isn't subject to local directory stripping (which removes the leading '/'), whereas the current URL is stripped for RewriteRules, hence the need for the slash in the RewriteCond.
outis
Yes, you're right, that's the solution, I forgot about the need of / in my answer.
silk
This variant of try #3 also makes the svn client return `405 Method Not Allowed`. Does not work.
Nathan
Can you try it on variant #1 and #2, adding the leading slash?
Pekka
A: 

Try

RewriteCond %{REQUEST_FILENAME} !(.*)svn(.*)
Xorlev
That's going to catch everything that has "svn" somewhere. Too broad.
Pekka
This variant of try #3 does not work. Still yields `405 Method Not Allowed` with the svn client.
Nathan
+1  A: 

I think you should call Dreamhost's support. I have some websites with them and always had good support.

Anyways, what about this solution?

SVN repository (SVNRepo)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} SVNRepo
RewriteRule . - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
GmonC
I chatted with a support person who said mod rewrite issues are outside their scope. :(
Nathan
z0mg!! the link you sent had a solution that finally works! `RewriteCond %{THE_REQUEST} svn` `RewriteRule . - [L]`I guess that was quite close to try #1. Now why couldn't I google or stumble on that? THANKS.
Nathan
and it is, apparently, `%{THE_REQUEST}` that makes the crucial difference between try #1 and the working solution. Not any of the flags like `[L]` or `[NC]`
Nathan
Well, I'm glad it worked for you! As the official mod_rewrite documentation http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html says, "Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.".
GmonC