I have a WordPress application mapped to the path '/' on my website. I want to add a subdirectory of non-WordPress PHP files. Ideally this directory could be located elsewhere on the filesystem, as it's part of a git repository.

I've tried making a symlink:

$ ln -s /home/username/project/public /home/username/webapps/wordpress/subdirectory

in the hope that accessing www.mydomain.com/subdirectory/index.php would display /home/username/project/public/index.php . But my WordPress .htaccess file (shown below) redirects to the top-level of my domain.

And I've tried using mod_alias in my .htaccess file but it appears this isn't allowed. I'd have to do this in the Apache conf, but the WordPress app doesn't seem to have one.

Any ideas how I can achieve this?

Here's my current .htaccess file, which I'm barely understanding:

    RedirectMatch permanent index.php/(.*) http://www.mydomain.com/$1

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com%{REQUEST_URI} [R=301,L]

    RewriteBase /

    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html|php)\ HTTP/
    RewriteRule ^(([^/]+/)*)index\.(html|php)$ http://www.mydomain.com/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} /+[^\.]+$
    RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    <Files .*>
    order allow,deny
    deny from all


asked 13 Oct '11, 07:26

philgyford's gravatar image

accept rate: 0%


You need to create a new symlink app using the control panel, named for example public_files, pointing to your /home/username/project/public folder.

Then, in your control panel again, you can edit your website record that your wordpress is being served and add that app to be served from the /subdirectory path of your domain.

Now, when a request cames for mydomain.com/subdirectory then our frontend nginx server will route it to that app instead of your wordpress blog.

Bare in mind that nginx should have at least read access to your /home/username/project/public folder in order to read and serve the files right.

permanent link

answered 13 Oct '11, 07:59

iliasr's gravatar image

iliasr ♦♦
accept rate: 36%

Thanks for that. I can't seem to make it work though - I've now got the two apps on my website, but if I try and access mydomain.com/subdirectory, I just get bounced to mydomain.com/ .

(13 Oct '11, 08:49) philgyford philgyford's gravatar image

Could you try reloading your page after clearing your browser cache?

If that's not working for you, then could you open a support ticket for us to give it a more thorough look?

(13 Oct '11, 09:26) iliasr ♦♦ iliasr's gravatar image

Weird... I tried again and for a while it seemed to work about 50% of the time, and the rest it kept redirecting to the top level of the site. It seems to work OK now - maybe some odd caching thing along the line - so thank you for the instructions!

(13 Oct '11, 09:34) philgyford philgyford's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Oct '11, 07:26

question was seen: 4,120 times

last updated: 13 Oct '11, 09:34

Features & prices    Sign up    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
© Copyright 2003-2015 Swarma Limited - WebFaction is a service of Swarma Limited