How to Fix “Repository moved permanently” Error in Subversion/Apache Setup


1 views

When working with Subversion through Apache, encountering the "Repository moved permanently" error (HTTP 301) can be particularly frustrating because:

  • Browser access works fine
  • Command line operations fail
  • Apache logs show cryptic messages

From the error logs and behavior described, we can identify several key symptoms:

[error] [client IP] Could not fetch resource information. [403, #0]
[error] [client IP] (2)No such file or directory: The URI does not contain the name of a repository. [403, #190001]

The most likely causes for this behavior include:

<Location />
   DAV svn
   SVNParentPath /var/www/svn/repos/
   # Missing SVNListParentPath directive
   AuthType Basic
   AuthName "Authorization Realm"
   AuthUserFile /var/www/svn/auth/svn.htpasswd
   Require valid-user
</Location>

Here's the corrected configuration that typically resolves this issue:

<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn/repos
   SVNListParentPath On
   AuthType Basic
   AuthName "SVN Repository"
   AuthUserFile /var/www/svn/auth/svn.htpasswd
   Require valid-user
</Location>

If the problem persists, verify these aspects:

  1. Repository permissions:
    chown -R apache:apache /var/www/svn/repos
    chmod -R 775 /var/www/svn/repos
  2. Apache modules:
    LoadModule dav_module modules/mod_dav.so
    LoadModule dav_svn_module modules/mod_dav_svn.so
    LoadModule authz_svn_module modules/mod_authz_svn.so

After making changes, test with these commands:

apachectl configtest
svn ls http://svn.host.com/repos/reposname

For Plesk-specific environments, you might need additional configuration in /etc/httpd/conf.d/zz010_psa_httpd.conf:

<Directory /var/www/svn>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

When trying to check out from an SVN repository hosted on Apache (http://svn.host.com/reposname), users encounter the frustrating error:

Command: Checkout from http://svn.host.com/reposname, revision HEAD, Fully recursive, Externals included
Error: Repository moved permanently to 'http://svn.host.com/reposname/'; please relocate

First, verify these key points:

  • Apache error logs show nothing initially (later shows 403 errors)
  • Local checkout works: svn checkout file:///var/www/svn/repos/reposname
  • Web browser access to the repository URL works

1. Location Directive Configuration

The most frequent cause is improper Location directive in Apache config. Try this instead:

<Location /repos>
   DAV svn
   SVNParentPath /var/www/svn/repos/
   SVNListParentPath On

   AuthType Basic
   AuthName "Authorization Realm"
   AuthUserFile /var/www/svn/auth/svn.htpasswd
   Require valid-user
</Location>

2. Repository Path Case Sensitivity

Linux is case-sensitive. Ensure the case matches exactly between:

  • URL path (/reposname)
  • Actual directory name (/var/www/svn/repos/reposname)

3. Permissions Issues

Run these commands to verify permissions:

chown -R apache:apache /var/www/svn/repos/
chmod -R 775 /var/www/svn/repos/
restorecon -R /var/www/svn/repos/  # For SELinux systems

Apache Module Conflicts

Check for conflicting modules with:

httpd -M | grep -E 'dav|svn'

You should see dav_module and dav_svn_module loaded.

Repository UUID Mismatch

Verify the repository UUID consistency:

svnlook uuid /var/www/svn/repos/reposname

Here's a complete working Apache virtual host configuration:

<VirtualHost *:80>
    ServerName svn.example.com
    
    <Location /svn>
        DAV svn
        SVNParentPath /var/www/svn/repos
        SVNListParentPath On
        
        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /etc/svn-auth-users
        Require valid-user
    </Location>
    
    ErrorLog /var/log/httpd/svn_error_log
    CustomLog /var/log/httpd/svn_access_log combined
</VirtualHost>

After making changes:

  1. systemctl restart httpd
  2. svn ls http://svn.example.com/svn/reposname
  3. Check Apache logs: tail -f /var/log/httpd/error_log