I am wanted to know that if there any settings in magento that we can remove fixed baseurl and keep dynamic(Relative) baseurl such as drupal.
It's not possible to have a relative base URL, but there's a good tutorial how to set base URL by an ini file in case of live/staging. You could adapt this to your needs:
http://maglife.co.uk/2009/03/28/magento-base-urls-and-devstaging-installations/
I would change it to read the base url from an Apache variable, which you could set per virtual host or directly read it from $_SERVER['HTTP_HOST'].
I have found that Magento sometimes will return an incorrect protocol (HTTP/HTTPS). To bypass this I've used hard-coded relative protocol URLs in certain cases (in phtml templates only) instead of calling functions.
Related
I'm using firebase hosting for my blog
I use this
mydomain.com/?postid=how_to_etc
Method to get my post data
Is there any way to use SEO friendly url like,
mydomain.com/how_to_etc
So that this link should not redirect to 404 error page
This kind of behavior requires rewrites configured with a single page app to interpret the URL path for its own router. this does depend on your current setup to determine the final work required.
alternatively, if you are using simple HTML; you can look at window.location properties and split the path with split.("/") to determine the path . See:
https://developer.mozilla.org/en-US/docs/Web/API/Location
As a new magento developer I'm using a theme to develop my store. I want to change the URL key of CMS page about. I followed the steps written here but I can't find my layout file for about page on the theme directory or base directory for change XML URL tag.
How can I edit the layout file? Can anyone help me?
Actually that tutorial is a little confusing because there, they are showing an example of changing a URL for two different type of pages (CMS and system).
For changing the URL of a CMS page, like about in your case, it's enough that you proceed until point 12. In short:
First. you change the URL from: (main menu) CMS/Pages/Your_Page -> Url Key: newURL
Then, find the blocks that it is used (e.g footer) and change the URL accordingly.
Plus, in general working in Magento after changing things like page URLs you need to do a reindex and in case of using cache you have to refresh/remove your cached data. Both could be found under System tab (Cache Management & Index Management).
I am working on a small project and all of my urls are written without base_url() function. So I was thinking what does those base_url() functions help with my urls. I know it will prefix the url based on configs file preferences. But simply I wanna ask
What is the advantage of using them ? and whats the disadvantage of not using them ?
The main advantage is that; when you want to migrate your project to online or in a different server; you won't need to edit your hard-coded links. The base_url() will make your inside links to get their base url dynamically.
echo base_url("blog/post/123");
will return
http://example.com/blog/post/123
in example.com and will return
http://jms.com/blog/post/123
in jms.com
base_url is needed when you create login/signup with email verification or forgot password functionality (Verifying by clicking the links like this http://yourdomain.com/auth/userid/code).
This is only one example, may have lot of uses.
the difference of base_url() and site_url() is that
both returns the url of your site but site_url() returns your site url, with attached index.php or on what you have configured $config['index_page'] = ''
in application/config/config.php
example www.yoursite.com/chicken/turkey
when using base_url(): Returns your site base URL, as specified in your config file.
you will get wwww.yoursite.com
when using site_url():
you will get www.yoursite.com/index.php
site_url() is usefull if you haven't change your .htaccess and you still access your controllers with index.php
base_url() is usefull when linking your css,js,or media stuffs. Granting that you still use index.php when accessing your controller/method
Its needed every-where, or at least we should use everywhere. Do you know, absolute url is far better then relative url? So, when you are using an absolute urls for all links on your site, instead of hard coded root domain name, you can use the "base_url()" function. Moreover, CI reactor is smart enough to detect the original base url, so you even don't need to enter it in config file.
I usually using the base_url() for the correct paths to the static files (css, js, img) files and the site_url() for the links to pages. site_url() will return with url_suffix witch could be set in application/config/config.php file
Advantage:-if you not use base_url() and you want to switch directory/server of your site , you should change the path all over the project.
if you use base_url(), just change it at onece in config.php ,effect on all site.
I was having a problem with my Magento checkout whereby the browser was reporting that the page wasn't fully encrypted. I had a look and realised that one of the images was using http://
This is the code I was using to display the image:
getSkinUrl('images/search_button.png') ?>
As a temporary solution I have hard coded the full path to the image ie:
https://mysite.com/skin/frontend/default/mytheme/images/search_button.png
Does anyone how I can call the image dynamically but have it use https on the checkout and other secure pages?
That should be solved by using the '_secure' parameter.
$this->getSkinUrl('images/search_button.png', array('_secure' => true));
Have you set your admin config settings to "use secure" (I can't remember the exact wording) for the frontend? If so, have you set your secure URLs to be HTTPS?
Magento generates image and link URLs via those secure/unsecure URLs you specify. If you haven't properly specified those as https://, you will have this problem. Otherwise, Magento is actually very good about outputting only secure content.
I haven't tested this for skin URLs, but for regular URLs you can do the following to force secure URLs. This is from the deep bowels of the URL code:
// Get the URL for another action on our current controller
// and force it to https
$path = "*/*/submit";
$url = Mage::getUrl($path, array('_forced_secure' => true));
There's probably some way to specify those extra arguments in getSkinUrl...
I have joomla site which is located in mydomain.com/somefolder/otherfolder/TheSite. I have created a rewrite rule to invisibly redirect all requests beginning with mydomain.com/TheSite to this url. It works fine.
My problem is that the urls that my menuitems point to are the old mydomain/somefolder/otherfolder/TheSite/stuff. If they were relative urls, it would work.
My question: How can I force joomla to use relative urls for the menuitems, or use the urls I explicitly specify?
Thanks in advance
Probably the easiest way to make Joomla produce only relative URLs is to edit the core method "_" of the JRoute class:
JRoute::_()
This is called by Joomla application and extensions to generate consistent URLs.
It is found in:
libraries/joomla/methods.php
Making Joomla spit out relative URLs probably isn't the best way to do it. Making the absolute URLs point correctly would.