2

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?

Community
  • 1
  • 1
Nathan
  • 3,842
  • 1
  • 26
  • 31

5 Answers5

4

How about

RewriteCond %{REQUEST_URI} !^/svn.*

?

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • 2
    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 Jan 30 '10 at 01:19
  • Yes, you're right, that's the solution, I forgot about the need of / in my answer. – silk Jan 30 '10 at 17:47
  • This variant of try #3 also makes the svn client return `405 Method Not Allowed`. Does not work. – Nathan Feb 01 '10 at 21:48
  • Can you try it on variant #1 and #2, adding the leading slash? – Pekka Feb 01 '10 at 21:53
4

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
  • 10,924
  • 1
  • 30
  • 38
  • I chatted with a support person who said mod rewrite issues are outside their scope. :( – Nathan Feb 01 '10 at 21:32
  • 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 Feb 01 '10 at 21:42
  • 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 Feb 02 '10 at 01:38
2

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
  • 31,028
  • 18
  • 69
  • 91
  • 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 Jan 21 '10 at 07:36
0

Try #3 looks good, have you tried there:

RewriteCond %{REQUEST_URI} !^svn.*
silk
  • 2,714
  • 22
  • 21
  • 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 Jan 22 '10 at 00:59
0

Try

RewriteCond %{REQUEST_FILENAME} !(.*)svn(.*)
Xorlev
  • 8,561
  • 3
  • 34
  • 36