I have a website based on magento and it works well. Couple days ago I downloaded the website to make a local copy, everything went fine, everything works.
but... on my landing pages, I use relative paths for my images and landing pages dont show the relative paths, I thought it was htaccess problem, so I enabled mod rewrite in xampp, AllowOverrides is on - All, downloaded htaccess file from ftp and copied in my local, development website root.
still the same problem. Example:
<br /> <img title="Headphones" src="/media/pages/home/headphones.jpg" alt="Headphones" width="442" height="200" />
(I edited html tags, it doesnt let me post them here, but they are correct on my websites)
This code works well on my live website, but on my localhost it doesnt load an image. When I check it in firebug, it says "failed to load given URL". URL is correct though, same url works well on my live website.
Any ideas please? help is much appreciated : ))
Edit: If I change relative paths of images in firebug and add two dots before the slash like this >> ../relative path here << then the images show up well, I dont get it, why does it show images on my live website relative paths without two dots in the beginning and why doesnt it show images on my localhost?
You have wrong idea about what path (note that url and path are different things) is relative and what is absolute:
this is absolute path from your domain root and those all are equivalent:
src="/media/pages/home/headphones.jpg"
src="http://localhost/media/pages/home/headphones.jpg"
src="http://productiondomain.com/media/pages/home/headphones.jpg"
this is a relative path from the page/dir you are visiting and are available from this point only (if defined correctly):
src="media/pages/home/headphones.jpg"
If your site is on localhost then your image is looked up from abs.url+abs.path and you should verify that the /media directory is on your domain root. If your site is on some subfolder on your localhost then the path just won't match and you should either rename all paths or add base dir rule to htaccess or base href rule to your html.
Related
So, currently, I do not have the ability to utilize .htaccess, I have no control over the server config at the moment, so I have to live with /index.php/ in my URL. That's not a problem, but there is one issue.
If I go to webserver.com/site/index.php everything works fine. But, if I go to webserver.com/site/ (without index.php) the site loads but all the links are broken (relative to /site/ instead of /site/index.php/).
I've tried various ways to build the links with url() and route() but I can't get anything to work short of hard-coding the full url for every link.
Any ideas?
I have been searching and looking for the answer to this for SO long now without any joy, I hope someone can help.
Okay I have a web structure of:
Main folder - This is where you first land prior to logging in. After you log in you will be either directed to a number of websites that are resident in a sub-folder called websites. The problem I have is that I would like the document root, say the $_SERVER['DOCUMENT_ROOT'] variable, to default to the root of the website folder that it has been directed to. You see I have a lot of $_SERVER['DOCUMENT_ROOT'] in my php code and I use the '/' slash a lot in the href on my HTML tags.
I have seen that I could accomplish this by adding a .htaccess in the root of eiach website folder but 1, would like work for my situation and 2, could anyone please help me with the code. I understand I can use the RewriteRule command but I can't get my head around it. My folder stricture is like this:
login (index.html)
websites folder
website1 (index.html)
website2 (index.html)
website3 (index.html)
I have tried many versions of using RewriteCond etc but non of them work.
If anyone can help me out here I'd be very grateful.
Thanks
Nothing you can do in your htaccess file that's going to be able to change the document root. One thing that you can do is create separate domains that you can make their document roots point to each of the websites folders. Then proxy to one of those domains.
That way the URL on the browser doesn't change domain names, and internally, you're proxying requests back to yourself and the individual website domains will each have their own document root.
I installed Drupal on my website. It works perfectly but to reach the front page I'm systematically redirected to a page called "Index of" and I have to click on the subfolder drupal-7.12/ to reach the front page. So, the real url for my website i guess is
http://www.mysite.com/drupal-7.12
On my ftp server is organized like this:
Folder public_html
-> Folder drupal-7.12 + a file .htaccess
There is another .htaccess file inside the folder drupal-7.12
I know that I have to modify one of them but i don't know which one and what i have to modify ?
I hope that someone will understand my problem and could help me
Thanks
ML
I would suggest that you remove the folder in drupa.7.12 and move everything up one directory. Basically you are set up as:
Mysite/drupal7.12
move all the contents of drupal 7.12 up one directory to your public_html folder
Or you need to edit the htaccess in the public_html folder to redirect you to that folder. But that is going to cause some issues in the long run.
if iam giving my url as http://localhost/york/aboutus.php it is working fine, but the problem i am having is that if i provide http://localhost/york/aboutus.php/ or any character after the trailing slash of the above url and then if load that page then all the css and javascript files are not working. Please provide me the solution to this problem.. Thanks in advance..
The problem is most likely the way you are including the javascript / css files in your page. With more details you will probably get a more detailed answer, but I would guess you are using .htaccess to rewrite the page in question and then in your html you are using a relative path for the src/link attributes of js/css. Every forward slash in your URL, the clients browser will assume is a directory and it will calculate relative paths accordingly.
The solution is to provide all your src/js paths relative to Root not your cwd. That is to say they should begin with a forward slash and then have the full path from your root directory. This way the clients browser will request http://www.domain.com/path/to/style.css, regardless of how many slashes are in the pages URL.
I am developing local websites and keep having problems with wordpress sites when they use relative links such as:
<a href="/wp-content/themes/mytheme/myfile.php">
This resolves to my localhost document root (htdocs) instead of the root of the job (htdocs/myjob).
Is it possible to use an .htaccess file in the root of the job (htdocs/myjob) folder to "fix" this behaviour? Or is it possible to put this htaccess file in htdocs, check the HTTP_REFERER, and send the browser to the correct site root?
Can you show me an example of the rewrite rule needed?
Any other suggestions would be welcome too.
In fact you mean absolute links. Relative links are what you want.
You should be able to configure the root directory in your Wordpress setup: this would be the correct approach.