I do have 5 shops:
http://www.mainshop.com
http://www.mainshop.com/subshop/
http://www.mainshop.com/subshops/
http://www.mainshop.com/subshops3/
http://www.mainshop.com/subshop4/
But everytime i click on the url for a categroy it keeps giving a Magento 404 error.
I did copy the index.php and htaccess to that subdirs and changed this line:
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : 'subshop1';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'website';
I also changed the configuration of that specific website:
The 404 comes to cms pages and category pages. Can't figure it out.
Magento creates a full links like this:
{{unsecure_base_url}}../skin/
http://www.example.com/shop/../skin/
which wont work ofcourse... Try inserting the full links ;)
Like this:
http://www.example.com/skin/
Have you used store views for each shop on one magento installation? You should not have sub directories for each shop and no need to copy index.php or any other file to a subdirectory. I think you have misunderstood how magento store views work. What you should do is enable the option for the storecode to be shown in each URL. When you setup your store view you specify the code which will be used (e.g. subdir1, subdir2 or whatever you want it to be). You need to use store views as you are using the same base URL which you need to change back to be default for each store view so it should be http://www.mainshop.com/ for every store view or website. This will allow you to achieve what you are trying to, without modding any magento code. Read this document in the wiki for more information how to do it properly http://www.magentocommerce.com/knowledge-base/entry/overview-how-multiple-websites-stores-work/
Related
I am looking to use some php pages I created as a template across multiple subdomain websites. I want to change minor things across each subdomain (what database is being used and some basic settings but this is not important). I do not want to copy over all files every time I want to create a new subdomain as this will be a pain when making updates. So I want to be able to push updates to my "live" site that acts as a template for all other sites.
This is my current testing layout
I have a "live" site that looks something like this:
-dashboard
-division
-division->lookup
Each of these directories have an index.php that I want included when the appropriate url is visited.
For each subdomain website, I currently have:
-.htaccess file
-errors (includes 404.php)
Within my .htaccess file, I have the 404 page as this 404.php page and that page looks like this:
if((#include "/var/www/live".$_SERVER['REQUEST_URI']."/index.php") === false){
echo "DOES NOT EXIST";}
If the url you are trying to go to exists in "live" it includes it and it basically mirrors it.
This seems to work except for when I try a url that is more than 1 directory deep. For example, if I am trying to go to test.myurl.com/division/lookup I get Google's 404 page (This test.myurl.com page can’t be found).
I am feeling like there has to be an easier way to do this and I am doing this all wrong. Where can I look to do this better? Any tips?
This will check if the file exists and should address the depth issue
<?php
$filename = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
if (is_file($filename)) {
// file exists as requested
require_once $filename;
exit;
}
http_response_code(404); // may be unnecessary
?>
<!doctype html> ... <!-- 404 page content -->
I am currently working in a application like wordpress. i need a php class to handle the url request for eg : if u load the below url in browser
http://somename.com/myaboutpage/
the handler should load the file about-us.php from my theme folder
and if i use the below url
http://somename.com/action/login/
the handler should trigger the file login-action.php from my application core and return the values
how its possible..
i tried to study how elgg & wordpress handle the request. but i am unable to get the exact..
so please help me.
Note the pages i create will be dynamic so i need a page handler fully dynimic like word press permalink handler
Have you set a BASE_URL in an index.php file? if you have, you could check to see if that is set, if it isn't it means the user has somehow managed to navigate directly to your about-us.php file. So something like
if(!defined('BASE_URL'))
{
require('/*your index.php file*/');
header('Location: BASE_URL')
exit;
}
I'm building a website with a custom content management system, and I want to build a slug area like wordpress. I want to retrieve the path name from my front-end depending on the page they're on, and echo that out in my backend in the slug area.
I'm using php and my front-end is dynamic, which means I have one page, and depending on what the user clicks on, I will include that file.
What I want the code to look like for the slug in the backend:
<?php
//front end path/ echo $slug;
?>
My front-end path looks something like this: blahblah/index.php/slug-name
I have a slug stored in the database that I will echo out, but my problem is I don't know how to retrieve the front end path and echo it out in the backend. I realize I can type the front-end path manually, but I think doing it dynamically would be better incase I move my website to a different location in the future.
I've tried using pathinfo or $_SERVER but that echos out my backend path rather than my front end.
Hopefully I was clear, if not, ask me to clarify something. Thanks again.
You need the rewrite module for apache or nginx.
That allows you to do like this:
PrettyPath(This will be seen to all visitors): http://blah.com/blah/bl/ah/test
=> RealPath(This can be used for develop): http://blah.com/blah/index.php?slug=bl/ah/test
You can do beautiful job like this for using rewrite module. (Rewrite Example)
$front_end_path = 'your/site/path';
$full_url = $front_end_path . $slug;
I'm not able to figure this out on my own so here I am asking for your help.
How do I load a website that I already made as a view in the code igniter default controller?
I put my website under a folder name site, and in the default controller I loaded the view site/index , but then in my site there are problems with the includes and redirects... I don't know why, I guess the way the site usually works with redirecting isn't compatible with code igniter style
edit: I guess I would have to turn off CI engine for this site, but I don't know why, because I would still need codeingiter to manage other parts of my application
"CodeIgniter can be told to load a default controller when a URI is not present, as will be the case when only your site root URL is requested. To specify a default controller, open your application/config/routes.php file and set this variable:
$route['default_controller'] = 'Blog';
Where Blog is the name of the controller class you want used. If you now load your main index.php file without specifying any URI segments you'll see your Hello World message by default."
http://codeigniter.com/user_guide/general/controllers.html
fragment copied from that link , you should put the controllers classname in that config, not the view
I guess it's better to choose one of these options:
Modify the existing site to a CodeIgniter site.
Keep your site separate from the CodeIgniter site, and just link between the two sites.
The way you are trying to do it seems very useless and causing a lot of extra trouble.
You can simply use the redirect function in your controller. If you supply a full URL you can go to any other page. You will, of course, leave your CI app.
redirect('http://www.example.net/page_in_external_site/');
Try using the APPPATH constant when defining the paths for the includes.
I know it's an old question, but you can try using a view template with an iframe, and you can pass the URL to the src property of the iframe. That way you can display your site inside a view, but still can't get access to the vars passed to the view from your site.
In system/Core/Loader.php change the line 141 to look like this:
$this->_ci_view_paths = array(APPPATH . 'views/' => TRUE, FCPATH => TRUE);
and to get the view is simple:
$this->load->view('application/ PATH_TO_VIEW');
I am currently working on a magento site that is in 2 languages (French and Dutch). The approach I am taking is as follows:
Create a folder in the web root (named nl)
Import the index.php and .htaccess file to that folder
In the index.php I modify the following line:
Mage::run('nl'); // to specify the store view i want to load
When I check, the categories, CMS content etc are still in the default language. The following code:
Mage::app()->getStore()->getName();
returns the fr store's name.
What is it that I'm doing wrong? I think a viable solution would be to set the store to run in index.php...
Could someone please let me know how to load a store by ID?
After hours of huffing and puffing i was able to figure out a way to set the store id programatically :)
In the index.php file, (in your language specific folder), add the following:-
$store_id = 'your_store_id_here';
$mageRunCode = 'store view code';
$mageRunType = 'store';
Mage::app()->setCurrentStore($store_id);
Mage::run($mageRunCode, $mageRunType);
Hope someone will find this information useful :)
You will get all store details here
<?php
$allStores = Mage::app()->getStores();
foreach ($allStores as $_eachStoreId => $val)
{
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
$_storeName = Mage::app()->getStore($_eachStoreId)->getName();
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
echo $_storeId;
echo $_storeCode;
echo $_storeName;
}
?>
To redirect to the specified store, you need to redirect the page along with the store code.
http://www.mywebsite.com/index.php/store_code/
Please check the template/page/switch/stores.phtml for more details
If the reason you're doing the htaccess stuff is so that you can generate URLs specific to each store, you may want to go with the configuration option that does that for you, should be in System > Config > Web