set files path in zend framework - php

im updating a project , the problem is that all images src and header links and etc have path like this:
src="/media/js/hoverIntent.js"
and i cant see every thing ok on localhost
when i delete the first '/' in src every thing is ok. but the project is very big and i cant delete one by one ,
how can i solve this problem.

Use mod_rewrite to point the failing URLs to the correct ones.
As example: your application uses URLs like /media/js/hoverIntent.js but everytime the URL begins with /media and you have the data stored on your dev server in /myapp/media/.... In this case you can solve it by placing following .htaccess in your root folder:
RewriteEngine On
RewriteRule ^media/(.*)$ /myapp/media/$1
Sure, you need to adjust the target URL of your files on localhost

Related

Custom directory viewer (php)

I started a little project a few days ago, a directory viewer. (Not a redesigned htaccess thing.)
It's written in PHP and works great except for a few little things.
I have one file (masterfile) where all parts of the viewer (css, php, ..) come together and build the final viewer. Whenever you access a directory without an index.php, index.html, etc. in it, you should end up in this masterfile and see your directory (-content).
Example: example.com/css/ => You're in css dir => Show custom dir viewer (css folder)
Idea: Disable .htaccess indexing which produces an 403 error, redirect this error to masterfile.
Options -Indexes
ErrorDocument 403 /masterfile.php
This does work, however it lists the content of the masterfile directory and not the content from original folder (example: /css/) Ideas?
Possible solution (I don't like): Put a file, that includes this "masterfile", in EVERY directory and name it index.php
I hope you guys have some ideas, I appreciate any help!
You can put something like this at the top of masterfile.php:
$parsed = parse_url($_SERVER['REQUEST_URI']);
$files = scandir($_SERVER['DOCUMENT_ROOT'].$parsed['path']);
maybe with some adjustment depending of your server configuration. The parse_url stuff is to remove eventual GET and/or segments.

phpgrid in Laravel 4.1 not working with domain masking

I'm using Laravel 4.1. I put phpgrid into the vendors directory. Here are my paths using example domains:
Actual file path to website root: /home/.../htdocs/dashboard/public
Actual file path to phpgrid: /home/.../htdocs/dashboard/vendor/phpgrid
The (example) url to the site is: http://www.site1.com/dashboard/
The SERVER_ROOT is set to: http://www.site1.com/dashboard/vendor/phpgrid
phpgrid works when I use that domain. The problem is that I want to use a shorter domain with masking. So the url I want to use is something like: http://dashboard.myotherdomain.com/, and the virtual host has it pointing to the actual file path to the website root directory above. phpgrid builds the table, but then the AJAX fires and can't get to the vendor directory because it is now below the site root of the masked domain. I thought it would use the absolute path, but it doesn't seem to. Any ideas?
It turns out that the issue was with the AJAX calls. AJAX will not let you call a different domain for security reasons, so setting the SERVER_ROOT to a different domain than my masked domain was failing (silently btw, blank error message in phpgrid). So I was forced to move the phpgrid files and folders into the webroot and change the SERVER_ROOT to a relative path.
A simple fix although I would have preferred to keep the files in the vendor directory.

Codeigniter Halogy cms installation setup

i have downloaded a halogy and after extracting i put the extract folder into my htdocs folder in my localhost ..i successfully setup the database but i am getting the error after visiting the url from the browser
this is the error
Slight problem...
This domain has not been configured properly.
my folder name after extracting
jesseorndorff-Halogy-35c4050
url
localhost/jesseorndorff-Halogy-35c4050
Here is a step by step solution
First rename your folder name with some thing else just for testing.
I changed jesseorndorff-Halogy-35c4050 to halogy_test.
Next cut system folder from halogy and paste it in the upper level. Now the structure will be like this.
localhost/
halogy_test/
halogy/
system/
index.php
Next go to database.php and set it up.
Next go to halogy/application/config/config.php and change
$config['index_page'] = '';
to
$config['index_page'] = 'index.php'; on line no 29.
Now go to application/config/site_config.php and change
$config['staticPath'] = '/static'
to
$config['staticPath'] = '/halogy_test/static';
The final step go to halogy_test/static/js/jquery.flot.init.js and change
'/admin/stats/' to stats/ on line no 2!
Done it
Vote up if successfull.
If you still have this issue after following the answer from #raheel-shan, then you'll want to take a look at the database you're using for your install of Halogy.
There is a table "ha_sites" that stores your sites path in the column "siteDomain". So even if you corrected the path to your site everywhere in your code, you'll still run into issues if the path in "ha_sites.siteDomain" isn't correct.
To fix this, do one of the following:
(easiest) Delete all tables, and re-import the sql dump.
or
Truncate the table "ha_sites".
or
Fix the path in "ha_sites.siteDomain".

Change in directory for FatFree framework does not work

I have started to learn the F3 framework (PHP) and I have gotten the Hello World program running.
However, I am facing a problem which is simple but I can't seem to get what am I doing wrong. When I keep the index.php file on the web root directory(/var/www) with the routing as -
F3::route('GET /', 'home);
and access http://localhost, I am getting the correct output. However, if I place the index.php file on the path /var/www/my_test/ and change the routing as follows-
F3::route('GET /my_test/', 'home')
and access http://localhost/my_test/ I get that the URL does not exist.
What am I missing here?
Hopefully you have been able to figure this out but if not, I hope I can help.
The .htaccess file is what points to the index.php page. If you change the location of the index.php file, you will need to modify your .htaccess. This is only if you change just the location of the index.php.
If you move the entire contents to a subfolder, I believe that folder becomes the BASE. So if you put the entire framework into /var/www/my_test/ then /my_test/ is the BASE and anything after that slash will be processed by the framework. http://localhost/my_test/ will be routed by using F3::route('GET /','home'); and http://localhost/my_test/abc will be routed by using F3::route('GET /abc','abc');.
You may still have to modify the .htaccess file for the folder, but I am not sure. On my computer, I created a virtual host so I could play around with it. Good luck!

PHP url functions and subdomains

I have a website thenoblesite.com. It has some subdomains i.e.
download.thenoblesite.com
wallpaper.thenoblesite.com
etc.
Pages for subdomains are present in the main htdocs folder i.e.
httpdocs/download <- download.thenoblesite.com
httpdocs/wallpaper <- wallpaper.thenoblesite.com
Problem is that I am using $_SERVER['DOCUMENT_ROOT'] . '/css'; for css folder and other common folders(graphics, includes, script etc). However in the subdomain page download.thenoblesite.com, $_SERVER['DOCUMENT_ROOT'] will refer to download.thenoblesite.com root folder, not the main thenoblesite.com root folder where css,graphics and includes folders are present.
I have to place the same graphics, css and includes folders separately on all subdomains. Every time I update the website I have to copy the common folders to all subdomains folders.
Another related problem is that i have to use absolute linking for the large sized downloads folder for e.g. VLC media player I have to use thenoblesite.com/download/vlc.exe or i also have to duplicate the large size download folder in all subdomain folders. This method unnecessarily increases the website size , creates confusion when I update the site and doesn't look good programming practise. Is there any possible PHP solution so that i can use the same css, images, downloads and includes folder for all subdomains....
I am not sure if this is something you might be interested in, but you could always create a new subdomain and call it something like style.[domain] and create a new variable in your config file and point it to that. this way you have all the images and css files etc stored in one place and if your traffic spikes you can always move that subdomain to a CDN etc so its really customizable.
UPDATE
ok so you can simply use a new variable in your config file like below :
$_config['http'] = 'http://www.yousite.com/';
now you can just use this variable to point to all your downloads etc on the main site rather than each pointing to the subdomain's folder. and if you want to be more flexible you can also add a few more css or js folders like :
$_config['http'] = 'http://www.yousite.com/';
$_config['css'] = $_config['http']."css";
$_config['js'] = $_config['http']."js";
the solution above will also help you if you decided to move the files around or just move a certain folder around etc. this is a good practice if you can adopt it.
You might be able to use an alias in htaccess (or the server config) :
Alias /images /home/username/public_html/images
If that's not possible, you could rewrite all requests to /images via htaccess:
# Untested - should get you on the right track though
RewriteEngine On
RewriteRule ^/images/(.*)$ http://yourdomain.com/images/$1 [R=301,L]

Categories