How to host multiple docarchives on a single http server?

I have a few different projects and a ton of tutorials I want to host on the same http server... is this possible? I watched the Host and automate your DocC documentation session, but it seemed to only work with those rules for one docarchive.

I know someone filed feedback for prefixes (https://developer.apple.com/forums/thread/682276)... is this possible already?

Thanks.

Answered by Developer Tools Engineer in 679034022

This should be possible already as you suspect. There will need to be additional server routing configuration to map the right requests for data URLs to the right doccarchive where the data actually lives.

For example, the same server could rewrite URLs for multiple frameworks/doccarchives so that the following applies:

  • URL path /data/documentation/A should map to A.doccarchive/data/documentation/A.json
  • URL path /data/documentation/B should map to B.doccarchive/data/documentation/B.json
  • etc

The example Apache configuration from the "Host and automate your DocC documentation" is hardcoded to the one SlothCreator.doccarchive example, but this configuration could be generalized to support more than one doccarchive.

If you can provide the specific server technology you're using (apache/nginx/etc), someone can probably help provide more explicit details on how to perform that kind of routing/rewriting for your exact use case.

Accepted Answer

This should be possible already as you suspect. There will need to be additional server routing configuration to map the right requests for data URLs to the right doccarchive where the data actually lives.

For example, the same server could rewrite URLs for multiple frameworks/doccarchives so that the following applies:

  • URL path /data/documentation/A should map to A.doccarchive/data/documentation/A.json
  • URL path /data/documentation/B should map to B.doccarchive/data/documentation/B.json
  • etc

The example Apache configuration from the "Host and automate your DocC documentation" is hardcoded to the one SlothCreator.doccarchive example, but this configuration could be generalized to support more than one doccarchive.

If you can provide the specific server technology you're using (apache/nginx/etc), someone can probably help provide more explicit details on how to perform that kind of routing/rewriting for your exact use case.

Thanks for the quick response! So I'm planning on using Apache and having a setup that looks like, for example, this:

~/public_html/docs/question_bot
~/public_html/docs/slothcreator

But before I even get to serving up the two separate doc archives, when I navigate to question_bot, I have an issue loading the css and js folders at the root, because in my public_html folder I already have css and js files that drive other parts of this site. So this rewrite rule in the .htaccess file is a bit of an issue:

# Route files within the documentation archive.
RewriteRule ^(css|js|data|images|downloads|favicon\.ico|favicon\.svg|img|theme-settings\.json|videos)\/.*$ QuestionBot.doccarchive/$0 [L]

(This rewrite rule is in a .htaccess file in the ~/public_html/docs/question_bot directory.)

Is there an easy way to amend this to not stomp all over my existing content? I can go digging into rewrite rules and regexp, but if there's an obvious way to support the setup above (and avoid requests for my docs going to /css and /js) I'm missing I'd love to hear it.

Thanks!

I've been playing with this and managed to get it to work on a single domain. I noticed most of the files had a hash at the end of them, so I merged them all down into a single .docarchive file. Of course, this may break in the future, but for now it works

# Delete existing .doccarchive
rm -rf templates/AllProjects.doccarchive

# Create a working folder
mkdir templates/working_dir

# Copy most files, excluding the index and metadata.json files to the working directory
rsync -a --exclude 'index.html' --exclude 'metadata.json' templates/ProjectA.doccarchive/* templates/working_dir
rsync -a --exclude 'index.html' --exclude 'metadata.json' templates/ProjectB.doccarchive/* templates/working_dir

# Copy across the index.html file from each Archive, but give it a new name when copying
rsync templates/ProjectA.doccarchive/index.html templates/test/projectA.html
rsync templates/ProjectB.doccarchive/index.html templates/test/projectB.html

# Create a new .doccarchive folder
mv templates/working_dir templates/AllProjects.doccarchive

You can then host this on your server and point to /documentation/ProjectA or /documentation/ProjectB. There is one current drawback I can see, the table of contents isn't unique.

How to host multiple docarchives on a single http server?
 
 
Q