Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


(Solved) WP HOMEURL and SITEURL questions
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

(Solved) WP HOMEURL and SITEURL questions

mehargagsmehargags Member
edited January 2016 in Help

Hi,
I maintain a busy (old) site for a client with hundreds of HTML pages and PHP scripts running in it. Their Marketing team wants to run a blog under the URL domain.com/blog but I was wondering, just to keep it safe and isolated (from FTP), can I install Wordpress under blog.domain.com yet still be able to run the blog using WP SiteURL as domain.com/blog ?

The Marketing guys are adamant they want the blog to be seen as from the SubDir and not from a subdomain... suggest ways I can keep WP installation "out off" the main site's directory.
Thanks

Comments

  • The "Site Address (URL)" setting is the address you want people to type in their browser to reach your WordPress blog.

    The "WordPress Address (URL)" setting is the address where your WordPress core files reside.

    https://codex.wordpress.org/Changing_The_Site_URL

    http://codex.wordpress.org/Changing_The_Site_URL#Changing_the_URL_directly_in_the_database

    https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    simplely google can do everything.

    Thanked by 1theroyalstudent
  • jarjar Patron Provider, Top Host, Veteran
    edited January 2016

    If you set the site/home URL to blog.domain.com and place it at domain.com/blog, domain.com/blog will redirect to blog.domain.com.

    Just put it in a subdirectory and make sure that any redirects you have at the domain do not conflict (assuming Apache, recursive .htaccess situation). Customer is boss, if it causes problems then they have to deal with them.

  • I'd just hire Jarland for $5 from fiverr and bill the client $1000.

    mehargags said: Hi, I maintain a busy (old) site for a client with hundreds of HTML pages and PHP scripts running in it. Their Marketing team wants to run a blog under the URL domain.com/blog but I was wondering, just to keep it safe and isolated (from FTP), can I install Wordpress under blog.domain.com yet still be able to run the blog using WP SiteURL as domain.com/blog ?

    The Marketing guys are adamant they want the blog to be seen as from the SubDir and not from a subdomain... suggest ways I can keep WP installation "out off" the main site's directory. Thanks

    jarland said: If you set the site/home URL to blog.domain.com and place it at domain.com/blog, domain.com/blog will redirect to blog.domain.com.

    Just put it in a subdirectory and make sure that any redirects you have at the domain do not conflict (assuming Apache, recursive .htaccess situation). Customer is boss, if it causes problems then they have to deal with them.

    Thanked by 1Junkless
  • mehargagsmehargags Member
    edited January 2016

    @jarland said:
    Just put it in a subdirectory

    @jarland said:
    If you set the site/home URL to blog.domain.com and place it at domain.com/blog, domain.com/blog will redirect to blog.domain.com.

    Just the other way around what I wish to achieve

    Hey Jar, Didn't quite understand your equation. I DON'T want to install WP into a subdir, but I want it to appear running from it. I want WP install to be done elsewhere without interfering the site's file/folders.

    I think (I'm reading) WP Multi-site options may have what I wish to achieve.

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2016

    mehargags said: I DON'T want to install WP into a subdir, but I want it to appear running from it. I want WP install to be done elsewhere without interfering the site's file/folders

    You could do a custom alias in the virtual host or mod_proxy then. You're going to really make this easier on yourself by just doing what the customer wants. You may not want it in a subfolder but if they do, tell them why you don't and then if they press just do it. Trust me on that ;)

    mehargags said: I think (I'm reading) WP Multi-site options may have what I wish to achieve.

    Multisite isn't going to help you direct domain.com to ~/public_html and domain.com/blog to ~/blog. Your problem is that the virtual host is pointing the domain to a folder and you want to say "Well, unless they type /blog to the domain then it needs to load from an entirely different document root." That is where custom alias or mod_proxy are going to be your best options. That absolutely has to be handled at the web server layer.

    https://httpd.apache.org/docs/2.2/mod/mod_alias.html
    http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

    I'm intentionally leaving out the idea of a symlink and quite frankly you should as well, given your criteria.

    Thanked by 1mehargags
  • I second what @jarland said.

    Communicate the potential implications from a security point of view. WordPress will technically run just fine in a sub-directory; however, if the site is compromised hackers could get access to the rest of the files. (As an aside, a subdomain probably wouldn't be as effective from an SEO point of view, if that matters; so your client may have some legitimate viewpoints).

    If I wanted isolation, I would probably use the alias method. Run WordPress as its own user in it's own directory separate from the regular site, but use an alias to map the location.

    At the end of the day, they're the customer and they're paying you. Document your discussions as best you can and just do what they pay you to do. You might lose them otherwise.

  • Thanks @Jar & @JustAMacUser for the mod proxy alias hint...completely skipped off my mind. Will try and post back my success ;)

  • Reverse proxy, as @jarland stated, is your best option. I've done this for clients who have large intricate CMS's but just want to run WP at like /news for putting up blog posts.

    You'll set WP to use the subdirectory URL, otherwise navigation links and stuff will redirect them away from the reverse proxy.

  • mehargagsmehargags Member
    edited January 2016

    Well, sometimes the solution is right under your nose and we can't make out. Thanks @Jarland for the hint...

    All I did was add this line to my Apache conf and it worked right away

    Alias /blog /home/abc.blog/blog/

    placed WP files in folder "blog" as /home/domain.com/blog outside of public_html directory

    fyi... this is a fresh blog that is yet to be started so there is no data or url links that may go dead.

  • @mehargags said:
    fyi... this is a fresh blog that is yet to be started so there is no data or url links that may go dead.

    That's the perfect solution then. I thought you were going to put it on like a separate VPS and have a subdomain setup for that - in which case you'd need to modify the WP URL settings to not use the subdomain, but instead the subdirectory.

  • @mikeyur said:
    That's the perfect solution then. I thought you were going to put it on like a separate VPS and have a subdomain setup for that - in which case you'd need to modify the WP URL settings to not use the subdomain, but instead the subdirectory.

    Well not for now, but I will think over doing this too ;)

    Anyhow... this simple thing is all I needed for now, to keep my filesystem "clean" of any other apps/frameworks as the main site uses a alot of business sensitive scripts.

Sign In or Register to comment.