Moving new folder to root - linux

I have created a new website for a client, (joomla) which is currently running within a folder in the root called /new/ (original I know)
I am now trying to work out what would be the best way to switch over the sites, there are a lot of files (pdf's, doc's etc) so moving everything would take some time, plus the old site is very messy, and would also take some time to remove in one go.
What about htaccess, and having a redirect? I could then remove the old site and files from the root over time?

One approach could be the use of symbolic links(ln -s basically), but you won't be able to do that for files that have the same name in both root and your new/ subdirectory. You will encounter this same issue with apache redirects, thus basically, you need to decide before hand what do you want to serve from either root or new/ and resolve the possible conflicts.

Related

How to change the root of a subdirectory

On my xampp server, I have several folders in /projects/ with different projects. The problem is when I make the link to the home page, I can't simply put in / because instead of going to localhost/projects/currentproj/, it goes to localhost.
Normally, I would just set all the href links to /localhost/projects/currentproj/, but I upload this project to a website so the website would have an incorrect link. I have temporarily set the links as local ones, with ./ instead of /, but I would like a more permanent solution if possible, and I don't know how to format htaccess files.
In other words, I would like to know how to change the root of a subdirectory, so all files in that folder go to the root of their own folder when linked to the root, rather than leaving that subdirectory.
EDIT:
Here is a perfect example of why this would be helpful.
That is what my 404 page looks like when I go to localhost/projects/currentproj/sub/example. If I could use / for the root of the currentproj folder, this wouldnt be an issue.
Here is an example of someone else with the same issue, but they never got a proper answer. There has to be a way to change this in the htaccess file.

Any way to set base url in the without reinstalling?

I built a site for a client on my subdomain. I then transferred it accross - files and data base - to a new server.
Problem is base url no longer works.
I manually set it, eg:
<base href="http://www.website.com/">
But this seems to make all links open in new tabs.
Is there any way I can fix this via the database or config file?
After moving a MODX site to another server, domain or subdomain, you need to check the following places and take actions:
clear the site cache (!)
check via FTP if cache folder is really empty
if not -> set permissions, ask your hoster if 777 or 755
edit templates to contain new base href
check your .htaccess if you have old rewrite rules set
check core/config for old paths or urls
also check config.inc.php inside root folder, inside /manager/ and inside /connectors/.
Most of the paths and urls in Modx are based off of the site-wide settings. There are probably several that you would have to adjust. core_path is the most basic of these.
These can be found under the gear in the top right corner of the manager, under 'system settings'
Also, if this and the config file are not enough alone, this SO question suggests re-installing the setup folder and re-running the initial setup.
Move modx site from subfolder to root folder

Redirect issue with cake php and html folder

I have a website in cake php host on a domain root(www.example.com/) directory it work fine. Now the issue is i placed a html template on www.exapmle.com/html but when i open this in browser it rdirect to website means www.example.com and seen cake php website.
One thing that is asked quite a lot on #cakephp is how to use other apps alongside CakePHP, and the answer giving is normally pretty ugly. Stick the files/folders in side webroot/. Although that does work, its not very nice. So ill show you a little trick with .htaccess files.
The first (really simple way) is to use a .htaccess inside the sub folder. For example you can have a copy of Joomla! running alongside cake with no issues when you have the .htaccess for Joomla! enabled. If the app does not have one and/or you would not know what to put in the .htaccess file you have another option
Make Apache stop processing rewrites if it finds a request for your sub directory. This is done by adding a rule for the sub directory and then telling Apache it is the last rule to process. The .htaccess file you want to edit is the one found inside your APP directory. All you want to add is the following line:
You can do this for as many sub folders as you wish, by changing the regex accordingly. Its pretty simple to do and a much cleaner way than having all your stuff inside the webroot/ folder of your APP.
Source : http://goo.gl/kOEZ9Y

Trying to move Drupal install TO subdirectory

Okay, so I've searched everywhere and while I can find plenty of stuff about moving a Drupal install out of a subdirectory I can't find anything on moving one into a subdirectory. I've recently taken over this project and it was developed without me so I've been landed in it here.
The problem is that the site was developed in the root of a dev server and I now have someone who wants it in a subdir. I've changed the base url in the htaccess and I've tried manually changing references in the CSS and DB but I can't be sure I've caught everything (modules etc).
What I want to know is, is there a way to force every link relative to the root to be relative to root/example instead. Basically everything that was once at www.example.com is now at www.example.com/subdirectory.
Thanks.
There's two pieces to this. The first you've already done: configuring htaccess to set a base url that includes the subdirectory.
Unfortunately, you may have quite a few references in the node content (especially embedded images) that will stop working.
A relatively simple solution to this would be to include a <base href="foo.com/dir" /> tag in your site theme, but this isn't a great fix in the long term.
You can try modifying your database directly, through queries such as the following (use with care, backup your database ahead of time, etc):
UPDATE field_revision_body SET body_value = REPLACE(body_value, 'devdomain.com', 'proddomain.com/subdir') (add http:// into those queries)
You may also need to update the paths in your files table to reflect the new locations on disk, especially if you're using multisite.
Alternately, have you considered using the Backup & Migrate module to move content from the dev server to a new install at the new instance?

Protecting folder and its files

I wish to protect folder with core files of CMS and its sub folders and files from accessing via web, and I tried with .htaccess file with this:
order deny,allow
deny from all
Problem I have is that I can protect that folder but some script from that folder or its sub folder then do not work good.
I also tried with this:
order deny,allow
deny from all
allow from 127.0.0.1
allow from 76.xx.xx.xx
In this case 76.xx.xx.xx is static IP of site.
Is there any way to prevent accessing files in that folder but still to make all work ok?
Another question.
I wish to secure more my site from hackers. So, is there any way to prevent injecting malicious files and code in my scripts/files and/or to block my site of executing files from other sites, hosts, to allow just working with local files.
I prefer .htaccess file, but if it is needed I have access to WHM if there is need for editing other files (but in that case I will need step by step guide). I am running site on Linux VPS with Cent-OS 5 system.
The usual way to do this is to put the accessible files in an apache-accessible directory, but all the rest into a directory out of the way from Apache. For example:
/usr/
local/
mycms/
public/
lib/
/var/
www/
mycms -> softlink to /usr/local/mycms/public
Or better yet, make mycms an alias in Apache config, pointing at the public directory. This way, the files that should be accessible are, those that shouldn't be aren't, and you can still reference all your other files simply by ../lib/ etc.
I know this does not really answer your question literally, and if the CMS directory structure is not under your control, this may not be the best way to do it.
Another way is through rewrites - simply rewrite all requests to your CMS directory except for your CMS's entry script into requests for the entry script.

Resources