How do I rewrite the phpbb directory to another directory? - php

I have phpbb in a directory of my joomla install which also happens to be inside a directory on the root (so that's me.domain.com/joomla/phpbb). I have successfully been able to rewrite joomla's directory to the root of a parked domain (me.domain.com/joomla/ --> domain2.com/ ) but when every I go to domain2.com/forum non of the style sheets work but domain2.com/joomla/forum works fine. Any help please?
Edit
I found that the css files werent being called properly. The page was calling from domain2.com/styles/ instead of from domain2.com/forum/styles/

Related

Issues with php include in sub domain

I just uploaded my site but am having issues with sub domain and php include.
First I have a directory /main/ and all it content are okay in localhost and also when I uploaded online until when I decided to forward www.main.example to main directory.
Now if I browse it this way www.main.example files that I include will not work, and also my css, but I manage to add full site name to my css and js like www.example.com/css/page.css and is working. So can someone help me with php path or any htaccess code that can help me fix this?
I tried this to but not working
include_once('../_inc/functions.php');
include_once(__DIR__ . '/../_inc/userlocation.php');

Some of the directories are accessible from public URL. How to avoid this in yii

In my Yii web application some of the directories are accessible from the public URL (main directory or application folder) like js, css, images etc. How to avoid this problem. This is a major security issue, but I don't know how to fix this. Please help me...
Thanks in advance...
If you're using Apache, you can restrict access to directories doing the following:
Create a .htaccess file in your directory so path/to/directory/to/deny/.htaccess
Open .htaccess and add Deny from all
You have to turn of apache directory listing. Use the link below.
How do I disable directory browsing?
Then change all files and folders permissions of a directory to 644 and 755.
Change all files and folders permissions of a directory to 644/755
Let me know if you need help
Here is some instructions given in documentation.
1) It's important that the directory be writable by the webserver user so that Yii can publish the resources there when needed.
2) When a project has multiple versions (production, testing, development, etc.) do not copy the assets/ folders from one area to another; allow Yii to deploy them automatically in each area.
3) Do not manually edit any file under assets/ - if you have a real need to make a change, find the publishing module, edit the source, delete the subfolder under assets/, and let Yii re-publish the updated files.
4) Do not reference names under the assets/ folder directly (say, to get at some other module's assets). If you need to use that
5) Do not add the contents of the assets/ folder to any source-code control system; these files have master source in other places.
6) It is safe to delete everything under assets/. Yii will re-publish the assets if they are not found under assets/.
Hope it will help you :)

PHP relative paths using home web server throwing errors

I'm using XAMPP on my home machine and also using it as a web server.
I have a main folder which is for my site, I then have a dev folder where I'm trying to work on a new site. (not sure if this is relevant info but worth mentioning)
On my local machine the site is c:/MySite/Dev
within Dev I have something along the lines of
Dev
assets
css
js
includes
footer
header
core
init
folder
subfolder
files.php
index.php
init is included at the top of every page, header and footer includes are also included. Within header is my nav bar.
I'm trying to define a site root so that I don't have to keep changing ../ and ../../ etc depending on the location of the files.
Also, seeing as my header gan be in many subfolders, the links to main index etc can get messy as index.php from a subfolder won't take me to the root index.php
I've tried using DIR and SERVER_ROOT bt of which I couldn't get to work properly, server root returned the c:/www and DIR returned the folder of the file in which it was called.
I'm still new to php so learning as I go.
This is what I've tried:
in init:
define("WEB", "http://mySite.com/Dev");
$environment = WEB;
echo $environment;
this works in the first instance, then when I'm in the subfolder and try using the home link I get :
http://mySite.com/Dev/Folder/Subfolder/%3Cbr%20/%3E%3Cb%3ENotice%3C/b%3E:%20%20Undefined%20variable:%20environment%20in%20%3Cb%3EC:/www/Dev/includes/header.php%3C/b%3E%20on%20line%20%3Cb%3E38%3C/b%3E%3Cbr%20/%3E/index.php
can anyone help please?
EDIT: The error after cleaning the output:
http://mySite.com/Dev/folder/subfolder/
Notice: Undefined variable: environment in C:/www/dev/includes/header.php on line 38
/index.php

Setting a root directory for accessing files from subfolders?

I am trying to create a root directory on my localhost(using xampp) so that I can link to images and folders found on the root from subfolders. So my directory is built like seen below.
Also, would this method work when the site is uploaded on the web? or would I have to change document root to http:// links to my site?
F = folder
f = file
My Site
-------
[f] index.html
[f] logo.html
[F] css -> [f] main.css
[F] news -> [F]1 -> [f] 1.html
[F] images -> [f]logo.jpg
logo.html will be included using PHP on every html page.
So if I include the logo.html in both index.html & news/1/1.html link to image doesn't work since the news file is on a different folder and link to the images folder changes.
I tried this using PHP but it seems I am doing it wrong:
<?php $root = $_SERVER['DOCUMENT_ROOT'].'/My Site/'; echo $root .'/images/logo.jpg';
?>
$_SERVER['DOCUMENT_ROOT'] gives you the real file-system path, not the path returned by Apache.
To link to the resource you need to use the HTTP path. If you want to link from the root you just need something like /images/logo.jpg
I found that on my PHPBB3.1 driven website using the "Pages" addin, the relative link would not remain 'static' in some link buttons at the top of my site.
From the PHPbb3 index page a link such as app.php/page/FT would produce an address of http://earth/forum/app.php/page/FT (Correct) ,but from the "Pages add in) that same link produced http://earth/forum/app.php/page/app.php/page/FT (incorrect).
I started looking for a way to set my page relative to the root of the web. I could NOT use absolute links because my site is replicated on other servers. I found the answer by trial and error. Simply add several ../../../ like this ../../../forum/app.php/page/FT
and it works.
Perhaps not the best of computer programming but it does the job.
In a nutshell with each ../ you step back a directory, put too many in and it goes back to the root but cannot go back any further!

Resolve links in include file

I have a site located at http://www.mySite.com. My html/PHP pages are located at http://www.mySite.com/index.php I have created a 'tabs' include file located at http://www.mySite.com/includes/tabs.html. And all is grand!
But I have started to need a bit more functionality and have added pre-coded pages/packages, like a blog. These packages are located in their own directories like http://www.mySite.com/blog.
The problem is the from the new package directories the links in the tabs include are no longer pointing to the correct URL because of the directory change. I understand why this is happening but cannot figure out a work around other than maintaining 2 separate tabs files, which seems wrong.
I had a very similar question that dealt with the css links and solved by adding a slash before the stylesheet path in the stylesheet link. Unfortunately it does not work in this situation also because in the different directory the include is '../includes/tabs.html'.
The tabs link is a standard html link:
<li>Home</li>
Again in my root directory files it works fine but if I put a file in a new directory like "http://www.mysite.com/newDir/index.php" the tabs are pointing to "http://www.mysite.com/newDir/tabURL.php" not "http://www.mysite.com/index.php".
Thank you again for your time,
Todd
All you need to do is update your links in the tab.html file to use absolute paths instead of relative paths.
<li>Home</li>
try including the tabs file using the full path on server no in your site directory e.g. www/mysite/includes/tabs.html

Categories