https://github.com/sumpygump/static-subdir
WordPress plugin for serving static files in a subdirectory
https://github.com/sumpygump/static-subdir
Last synced: 11 months ago
JSON representation
WordPress plugin for serving static files in a subdirectory
- Host: GitHub
- URL: https://github.com/sumpygump/static-subdir
- Owner: sumpygump
- License: mit
- Created: 2014-03-30T06:02:49.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2014-04-23T14:01:23.000Z (over 11 years ago)
- Last Synced: 2025-01-04T14:17:42.618Z (about 1 year ago)
- Language: PHP
- Size: 164 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Static Subdir WordPress Plugin
This plugin allows you to specify a virtual URL path and have static content
served from a provided directory on disk.
Example: Set the virtual path to a value like `downloads`, meaning that users
could visit `http://mysite.com/downloads/example.txt` to download the file.
The plugin will look for the file `example.txt` at the path specified by the
*real path* setting.
## Prerequisites
This plugin requires:
- PHP 5.3+
- [composer](http://getcomposer.org).
If you don't already have composer installed on your system, please follow the
instructions at [getcomposer.org/download/](https://getcomposer.org/download/).
I recommend a system-wide installation in your `~/bin` directory. Make sure
this path exists and is in your systems `$PATH`.
$ cd ~/bin
$ curl -sS https://getcomposer.org/installer | php -- --filename=composer
## Installation
1. Clone this repo or put the .zip file of this plugin into the
`wp-content/plugins` directory of your WordPress site. It should be at
`wp-content/plugins/static-subdir`.
2. In a terminal, run the command `composer install` while in the static-subdir
directory. This will install the dependencies and put them in the `vendor`
sub-directory.
3. Go to the Plugins page in your wp-admin to see the plugin and activate it.
## Usage
Once activated, there will be a settings page where you can set the following
fields:
- Virtual Path
- Real Path
The *virtual path* is a sub-path for your static files from the root of your
WordPress URL. Setting it to `downloads` will designate the path
http://mysite.com/downloads to be the place where your desired files will be
served.
The *real path* is a location on disk (relative to the WordPress site root, or
ABSPATH) where the directory exists where the files are stored.
Set these two values as desired and then click the button Save Changes. This
will register a rewrite rule with WordPress for the virtual path. Note that you
must enable permalinks on your site for this plugin to work. Do that in your
wp-admin panel under Settings > Permalinks. The value must be set to anything
other than "default."
## Supported Content-Types
The plugin will serve up files in the real path specified and will send the
following MIME types in the `Content-Type` header for the following file
extensions:
- css: text/css
- gz: application/x-gzip
- html: text/html
- ico: image/ico
- jpg: image/jpg
- json: application/json
- js: text/javascript
- log: text/plain
- png: image/png
- rar: application/x-rar-compressed
- tar: application/x-tar
- txt: text/plain
- zip: application/zip