Magento base url not reflecting value changed in database (missing /) - magento

This is one of those things that on the surface of it seems very simple to resolve, but it's got me beat!
I can see from searching around that quite a few people have had this issue crop up but there seems to be no solution that I can find.
What I've done:
1. Transfered my site from the root folder into a /shop folder.
2. Changed the database entries for secure/unsecure base urls to https://www.dnabaits.com/shop/
3. Cleared out all the Cache and Tmp files.
What's happening:
The whole site is functional but no styles or scripts are being loaded because the paths in the head are missing the trailing / after shop.
So instead of getting this
mydomain.com/shop/skin/........
I'm getting mydomain.com/shopskin/........
An example Url from my page source
<link rel="stylesheet" type="text/css" href="https://www.dnabaits.com/shopskin/frontend/default/dna/css/lightbox.css" media="all" />

In your .htaccess file make sure you have this (with trailing slash):
RewriteBase /shop/
Another possibility is that your Store Configuration Scope for your Store View has a different setting. Change your Configuration Scope in Admin -> System -> Configuration -> Web and make sure your URL settings aren't customized there.

Related

Loading resources in Laravel Valet without trailing slashes

I have a simple html file (trying to start my way with valet) and in it i have a <link rel="stylesheet" href="./css/main.css">
Thing is, home.test/app doesn't show my styled htm. Chrome's inspector shows it tries to find the resouce file at home.test/css/main.css
While in home.test/app/ it is *not* styled.
Ive been googling a cause/fix for some time and i cant wrap my head around it.
I have tried copying some of Statamic's valet driver configs without much success as a www.conf file.
Also, ive seen some rewriting methods like
rewrite ^/(.*)/$ /$1 permanent;
rewrite ^/?(.*)$ /$1 break;
also without success
I'd like to access home.test/app and have it load all required files and if possible to redirect home.test/app/ to home.test/app removing the trailing slash
The issue is likely to be down to the use of ./ in the href of the link. You're telling the server "go grab me the file from the folder /css/main.css from my current folder location.
Assuming your folder structure is:
/index.php
/css/main.css
/app/index.php
When you're on the home page, you're saying go and retrieve home.test/css/main.css. However, when in the app folder, you're telling the server to go and retrieve home.test/app/css/main.css, rather than home.test/css/main.css.
The quickest solution will be to change the link to <link rel="stylesheet" href="/css/main.css"> (getting rid of the leading .). Otherwise you can use an absolute path.

CSS not Loading in Magento

I'm having a problem with my magento, CSS is not loading.. and when I take a look on its source. There's a problem with my path..
link rel="stylesheet" type="text/css" href="C:\Program Files (x86)\Zend\Apache2\htdocs\mycommerce_comhttp://mycommerce.com/skin/frontend/base/default/css/style.css" media="all" /
C:\Program Files (x86)\Zend\Apache2\htdocs\mycommerce_com is not supposedly in the path.
the correct path must only: http://mycommerce.com/skin/frontend/base/default/css/style.css
Whats the solution for this? I already did all the solution given by google.
Still no luck.
can you check under System => Configuration => Web, under both Secured and Unsecured tab the value of skin folder, if you website is running correctly then I assume you have your base URL correct. If so then the value for media and skin should just be:
{{secure_base_url}}skin/
{{unsecure_base_url}}skin/
If you go to the controlcentre
System => Configuration => Web
The main point to watch out for is
i. Url options -> Add store code to Urls should be 'No'
ii. Unsecure -> Base Url should point to your own domain e.g http://mycommerce.com/
iii. Secure -> Base Url should point to your own domain e.g http://mycommerce.com/
also you should have
{{unsecure_base_url}}skin/
for your Base Skin

Hide directory in source code

Actually my question is How is folder path hidden ? Firstly I am using Joomla.
I found a website 4 months ago, so i don't remember name of the website which is Joomla site. They hide their folder path.
Between to head> sth. head(tags). If you look at source code, you can see this part. And then this part include template name.
For example:
<link type="text/css" href="http://www.site.com/templates/template_name/css/style.css" rel="stylesheet"></link>
So we can learn to what the name of the template. But they hide this part. When i looked this part(http://www.site.com/templates/template_name/css), i can see only /style.css.
Do you have any idea?
You need two things to accomplish that.
A (system) plugin, that changes every template related URL to the 'official' format, eg.
$url = str_replace('/templates/template_name/css/', '/style/', $url;
An .htaccess redirect reverting the change.
RewriteRule ^style/(.*)$ templates/template_name/css/$1 [R=301,L]
If you want obscure template names, and a few modules and plugins from HTML source, the easy way is use a CSS and JS compressor like jbetolo or RokBooster.
But keep in mind that you will make a bit more hader to find your template name, but still possible via other ways. Like some images if they are not compressed in HTML.

How to link assets(images,stylesheet etc) in Views for CodeIgniter 2.1?

I am using CodeIgniter Version 2.1 & trying to link assets like images,stylesheets, javascript files etc in my views by using, header.php:
<link href="<?php base_url();?>css/style.css" rel="stylesheet" />
my controller code, calls the view:
<?php
class Main extends CI_Controller{
public function index() {
$this->load->view('header');
}
The view file from which I am trying to load the asset is located
../application/views/header.php.
the css file is loaded:
../application/views/css/style.css
this does not work. I get 404 - Page not found error.then, I tried moving css/style.css outside ../application directory in webroot. To my surpise, having assets in webroot(outsite ../application/views) seems to work nicely.
Now,
My Question is
Is having our assets directly in webroot, outsite ../application directory right approach? If YES/NO, then why?
If having assets directly in webroot is a good idea, than should I move ../application/views directory in webroot as well? How?
PS: I am new to CodeIgniter framework, so unaware of the best practices
If you see this, the section where .htaccess is used to remove index.php from the urls, that has a rewrite condition:
RewriteCond $1 !^(index\.php|images|robots\.txt)
In this line, images is a folder that will be ignored while mod-rewriting. So, you can replace it by assets, put all your directly linking files there, and happily use them.
RewriteCond $1 !^(index\.php|assets|robots\.txt)
EDIT: my bad, hadn't seen the date the question was asked. nevertheless, should be useful for someone.
It is best to put your assets in the webroot folder. When requesting assest from the server (depending on your setup), it will start from the root directory and work it's way down.
http://yoursite.com/application/views/css/mystyles.css
if it's in the root you only need to go from there
http://yoursite.com/css/mystyles.css
Although it might be worth putting them all inside a folder (/assets) to keep them contained, as well as the ability to write a more effective rewrite rule (if you are trying to remove the index.php from the url) to ignore the single folder instead of all the individual folders (/css, /js, etc)
As for the views folder, it's best if you leave it in the application folder as CodeIgniter has a built in loader that automatically checks /application/views for the view file when you use the code $this->load->view('myview')
Although there are way to move the views folder, if you are new to CI it's probably best to leave it there for now.
For linking css you can do something like:
echo link_tag('css/mystyles.css');
Check this for ref: http://codeigniter.com/user_guide/helpers/html_helper.html

resolving urls to some other url for development purposes

I am working with both asp and asp.net pages together. I wanted to host the application in my local iis (v5.1) but later learned about iisexpress suits my needs. But irrespective of whether I use iis 5.1 or iis express I seem to have an issue.
The asp page which I work with refers to static resources (css, javascript, etc) which reside in a different virtual directory. For e.g. a css file include would look like this.
<link rel="stylesheet" href="/common/include/style/css.css"/>
If such a thing is supposed to run from the test environment then the above url would resolve to:
http://testing/common/include/style/css.css
This is in contrast where my main application would reside. That would look something like:
http://testing/myapp/default.aspx
Now if I run iisexpress in say port 8082, and there is an inbound request like:
http://localhost:8082/common/inlcude/style/css.css
it will hit a 404 error. Is it possible to instruct iss or iis express to resolve such url (which begin with /common/...) to say http://testing/common/...
Update (May 31st 2011, 7.04 PM IST):
Been doing some research on what url rewriting is, and from the examples I have come to understand a few things. I am not sure if what I want is url re-writing, per se. Again taking the iisexpress analogy, I know there will be an inbound request uri like:
http://localhost:8082/common/inlcude/style/css.css
But I want this to be actually served by the following uri:
http://testing/common/include/style/css.css
The former uri doesn't exist in the folder which I have virtualized using iisexpress.
Do I need url re-writing here?
Further, in ASP, I have include lines like:
<!-- #include virtual="/common/include/classes/utils.asp" -->
Even these things are supposed to be resolved to their corresponding http://testing/... counterparts.
ps: I am doing all this is iis 5.1
In ASP.NET 2.0 onwards you can use the tilde operator (~) which is used to specify where your application is rooted. For example:
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
Would produce a relative url:
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
This works fine for ASP.NET pages.
Classic ASP and static HTML pages are a different story and one or more of the following mechanisms would have to be used:
Make everything relative. If you have a page or ASP script in the root of the site, instead of specifying /common/include/... specify common/include/.... If you have a page or ASP script in a subfolder the you'd reference your CSS by way of ../common/include/..., i.e. parent paths. The deeper the folder structure the more ../ parent paths you have so managing these relative paths can get messy. Also, although not common these days, some shared hosted servers disallow parent paths.
Prefix your CSS paths with a variable containing a path prefix. For example:
<link rel="stylesheet" href="<%=Session("RootPath")%>/common/include/style/css.css"/>
In production you'd globally set the session value RootPath to /MyApp, but for testing leave as an empty string. You could do this in Session_OnStart in your global.asa. You could also use an application wide value Application("RootPath") instead. This would only work for ASP pages.
URL Rewriting - if you have static HTML pages then URL rewriting can come to the rescue. You would rewrite the absolute url's which work on your dev PC to the path used on the production server. So basically every time you see a href="/common/... you'd rewrite to href="/myapp/common/.... IIS6 doesn't support rewriting out of the box, you'd need a third party tool such as Iconics IRF or HeliconTech's ISAPI_Rewrite3. IIS 7.x does support URL rewriting through the URLRewrite Module 2.0.

Resources