Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

htaccess guru wanted :)

I am hoping someone can help me. I am considering moving to a new hosting company so brought up a copy of my website on their servers. Initially I brought it up in a subdomain which on their system means it is in a subfolder of my root web location.

So I had wp.domain.com which pointed straight to a folder called wp within my public_html folder. WordPress is installed in the root of this wp folder and Vanilla in a subfolder called forums. Pretty URLS are turned on for both wp and vanilla and so I end up going to wp.domain.com/forums to get to my vanilla forums and then everything in there is under this (e.g. wp.domain.com/forums/categories etc).

Now this all seems to be going quite well and I decide I want to go live. Unfortunately it turns out that I can't just point the main www.daomin.com address to the same wp subfolder folder. The www.domain.com site always has to point to the root of the public_html folder. I don't really fancy moving all the messy WordPress files and folders up there as it will then be mixed in with any folders associated with subdomains.

I managed to come across a URL rewrite rule that solves the problem by redirecting anything for www.domain.com (or domain.com) to a subfolder. I've placed the following .htaccess file in the public_html folder

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteRule (.*) /wp/$1

WordPress now works as expected. The only problem I get is that my Vanilla forums now show up as

http://www.domain.com/wp/forums rather than http://www.domain.com/forums. All of normal WordPress pages and images etc show up with the wp folder hidden (e.g. http://www.domain.com/page not http://www.domain.com/wp/page), it is just Vanilla that is showing the unwanted wp folder in the path.

So finally to the request...does anyone know how to create a rule to hide this and in what folder would I need to place it (public_html, wp or forums)

I already have an .htaccess file in the forums folder that contains the following

RewriteBase /forums
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]

Thanks

Alan

Comments

  • LincLinc Admin
    edited December 2016

    On a new line after RewriteCond %{REQUEST_URI} !^/wp/ I would try adding RewriteCond %{REQUEST_URI} !^/forums/. That should chain the two rules together and stop anything in that folder from redirecting.

  • Thanks Linc, unfortunately that caused 404 errors in the forums folder

  • decided to pull the forums folder out from within wordpress and put it in its own root folder. Keeps vanilla and wordpress separate and still looks the same as the original development site as far as URLs i.e. forums still at www.domain.com/forums.

Sign In or Register to comment.