Closed dahlo closed 9 years ago
The only way i could get the server to serve the pdf file was to link it like this, link to pdf, that is a link that is relative the web server root.
For existing files you have to prepend content/
, because that points to the physical directory on the server and Phile doesn't do any URL magic except for the markdown files.
Any suggestions?
You could use an additional rewrite rule to serve files from content/
. This should work:
RewriteCond </path/to/phile/>/content/$1 -f
RewriteRule (.*)$ content/$1 [L]
But I suggest to filter for file types if you don't want to serve everything (e.g. raw .md files).
Yeah, I was also confused with that some time ago, and I think all newbies also did.
I do not test RewriteCond
yet, but it is apache/nginx/webserver spesific.
Solution may also be a plugin
file-name.pdf
(any needed extension) into the link to the data folder (i.e. like @james2doyle 's phileInlineImage does; also we can extend his plugin).md
file is.@Schlaefer, what do you think about that?
@Frodox plugin is possible too.
A generic replacement of URLs in the document feels like a pita:
content/foo/bar.png
or does foo/bar.png
exist?I would probably not alter the links in the document but intercept the incoming request in Phile and serve the appropriate file through PHP. If performance ever becomes a problem switch to a web-server rewrite.
Write your own plugin like phileInlineImage. Or create a simple snippet with the snippet plugin.
Ah, i see, thank you very much for the suggestions! I ended up going with modifying the .htaccess file in Phile and added this:
RewriteCond %{REQUEST_URI} .*\.(jpe?g|gif|png|ppt|pptx|doc|docx|pps|ppsx|pdf)$
RewriteCond <path/to/phile>/content/$1 -f
RewriteRule (.*)$ content/$1 [L]
Seems to be working for my purposes. Thanks again!
Is "foo/bar.png" really content/foo/bar.png or does foo/bar.png exist?
Yes, I thought about that too and it is not best choice.
Or create a simple snippet with the snippet plugin.
Oh, I seen some plugin but forgot it's name. That is! So alternative way will be to create snippet and include it into @infostreams 's repo. Plugin will extand syntax so we can link to files in same folder (I do not know how to get .ms
's folder, but I believe it's possible:) ).
@dahlo feel free to close the Issue.
I use the following additional rewrite rule so that I can reference additional resources relatively from my pages:
RewriteCond %{DOCUMENT_ROOT}/content/$1 -f
RewriteCond $1 !\.(md)$
RewriteRule ^(.*) content/$1 [L]
Would something like this be worth including in the standard .htaccess, even if just commented out as an example? If the Phile is setup as the document root it works as is. Otherwise one would just need to add the path to Phile into the RewriteCond which is a minor modification.
Hi there
Thanks for a wonderful CMS, it's really everything i have been looking for! I noticed an irregularity while trying to link to a .pdf i have in the same directory as my .md files. I could not use a relative link to work for anything but .md files.
Ex.
I serve my phile on it's own domain, eg http://domain.com serves the content in my
phile/
directory.I have 3 files as follows:
phile/content/index.md
phile/content/sub/index.md
phile/content/sub/file.pdf
From
index.md
i can link tosub/index.md
by using a relative link,[link to sub](sub/index.md)
but i cannot get the web server to serve the pdf file by linking to it with a relative link,[link to pdf](sub/file.pdf)
The only way i could get the server to serve the pdf file was to link it like this,
[link to pdf](content/sub/file.pdf)
, that is a link that is relative the web server root.Any suggestions?
Cheers Martin