laravel 5 redirect route to external url - laravel-5

I am in the process of moving a website to a new version of the site that has been created to Laravel 5,
However, I need to link to some old static content in a subdirectory on my old site, so I would like to create a route that automatically re-directs any querys to a specific sub-directory to to the old site.
For example:
user goes to:
www.site1.com/brochures/brochure1
I want it to redirect to:
www.oldsite.com/brochures/brochure1
And I want to have it do this for anything that comes in as
www.site1.com/brochures/whatever ...
I want it to duplicate the same path but redirected to the old site. I don't want to have to put in each brochure, as every once in a while a new brochure gets added...

Something such as
Route::get('/brochures/{brochure}', function($brochure){
return redirect('http://othersite.com/brochures/'.$brochure);
});

Can you try this:
return redirect()->to($path);

Related

How to load an codeigniter application by using different url

Now I am developing an application by using CodeIgniter framework. In this application, there is a section which name account setup. By using this section we can create multiple accounts. As an example, accounts name are abc, bca or anything. And Suppose my site URL is: www.xyz.com (base_url) Then we need to access the site by the domain name and also domain name with account name like bellow:
www.xyz.com
www.xyz.com/abc/
www.xyz.com/bca/
www.xyz.com/anything/
For More clear, URL pattern will be:
www.xyz.com/dashboard/index
www.xyz.com/abc/dashboard/index
www.xyz.com/bca/dashboard/index
How can we do it? I need your suggestion.
Yes it's Possible through codeigniter Routs.
Go to application\config Open a file which Name is routes.php
you can call the controller functions see in code example
example
$route['new_project'] = "controller/function";
when you hit your website url like this www.xyz.com/new_project it will go to your mention controller and function.
see the documentation of routs CodeIgniter URI Routing
example 2:
$route['account/(.*)'] = "controller/function";
Now we you redirect your url like this
redirect('account/'.$name_var.'');
Now your url look like this.
www.xyz.com/account/name_of_logged_in_user
Also you can use this like this.
$route['(.*)/dashboard/index'] = "controller/function";
And then you can call it like this.
redirect(''.$name_var.'/dashboard/index');
And from this code your output url show something like this.
www.xyz.com/name_of_logged_in_user/dashboard/index
Hope it will help you if any question add comment
There are many way to do it.
1) Domain alias if you want to run same script with different domain.
2) if you want to run same script with sub domain then you can do it from Cpanel
3) If you want to run same script with different folders in same domain then you need to use htaccess

Codeigniter - Htaccess : How to change a controller name

This is my first question here, so Hi all! ^^
I created a website with codeigniter framework and I have inserted a module for multilanguage. The url looks like this:
http://www.mywebsite.com/en/controller/function
The problem came when the client wanted to send a newsletter to all its customers in another language, but do not want to send the url with the controler with the name in english, because the newsletter is for spanish users.So:
URL is going to be send:
http://www.mywebsite.com/es/thecontroller
URL the client wants to be send ("elcontrolador" is "thecontroler" in spanish):
http://www.mywebsite.com/es/elcontrolador
I dont want to create another controler named "elcontorlador" only to show the same page as "thecontroler", because we don't want duplicate content for SEO purposes.
So, i want via .htaccess, a rule that when i type
http://www.mywebsite.com/es/elcontrolador
in the URL, mywebpage shows the info of
http://www.mywebsite.com/es/thecontroler
but with the URL
http://www.mywebsite.com/es/elcontrolador
(the controler "elcontrolador" doesnt exist).
So, is there any way to do this with the htaccess? I've tried it myself but I failed miserably i come here desperate, because I run out of time to deliver it and can not find a viable solution. I'll have to create the extra controller?
Need help D:
Maybe you can use the route config file instead to achieve this ?
$route['es/elcontrolador'] = 'es/thecontroler';
I don't know how you handle your multilangage, but you've got the idea.

Getting current Prestashop user in external site

In order for me to get a Prestashop user's cart, I first need to know who the user is in my external CodeIgniter application.
I have tried various attempts like the following: http://www.prestashop.com/forums/topic/204227-webservice-and-check-if-user-is-logged-in/ and http://www.prestashop.com/forums/topic/156218-solvedish-integrating-prestashop-into-a-pre-developed-website/ and even Prestashop: Session cookies & login and http://webilyst.com/prestashop-cookie-structure/
But I could not get it working. For some reason, the moment I include config.inc.php, it redirects to the shop - instead of allowing me to get the ID required.
My question: Any idea how to get this current user ID from PrestaShop in external epplication?
Edit 1
I am using CI 2.1.4 and PrestaShop 1.5.6.x.
Edit 2 Seems like the articles I have read is for an older version of PS. That code actually gets to a point where the Shop is being initialized, and once that is done, in Shop.php, the user is redirected to the shop. I do not want this to happen - I just want to find out who the current logged in user is.
You can get the current customer ID with the following code:
include($prestashopBasePath . '/config/config.inc.php');
$context = Context::getContext();
$customerId = $context->customer->id;
The reason why you are redirected is that you execute the script from a URL that is different from the shop URL defined in back-office -> Preferences -> Set shop URL. For example the shop URL is example.com/presta and your script is in example.com/other/script.php.
The solution is to move your script to the PrestaShop directory.

mydomain.example redirect to mydomain.example/store for Magento store

I currently have a domain landing page which I want to get rid of. The landing page (mydomain.example) links to a blog and a Magento store (mydomain.example/store) but I want to the domain to link directly to the Magento store.
I set up a redirect using my hosting company's domain redirect tool on mydomain.example to mydomain.example/store, but this results in a redirect loop mydomain.example/store/store/store/store etc.
Should I be setting up a redirect anyway? It makes more sense to me to just set my Magento storefront as mydomain.example and get rid of the /store on every page within the store.
I decided that a redirect was not the answer here, so I moved the Magento store from the subdirectory /store to root. I followed these instructions:
http://www.crucialwebhost.com/kb/move-magento-to-another-directory/
But I copied files from store rather than moved them. This way you can revert back quickly if anything goes wrong.
Simply create index.html that contain this meta tag.
<meta http-equiv="Refresh" content="1; url=http://www.example.com/store">
Change example.com to your domain.
First you need to add jQuery core library and jQuery Cookies library on your WordPress site:
jQuery Library
jQuery Cookie library
Then use this jQuery code in the header.php file.
var redirectStore = jQuery.cookie("redirect");
if(redirectStore!="yes") {
jQuery.cookie("redirect", "yes",{path:'/'});
window.location= "http://www.mydomain.example/store";
}
It is checking if a "redirect" cookie is already created or not. First time users will not have this cookie. Then it redirect to mydomain.example/store and creates the cookie. If the user comes back to blog site while visiting store then it will find the redirect cookie to prevent an infinite loop.

Loading an MVC site

Hello I am in desperate need of help. I just created an MVC site made in Visual Web Developer 2010
and each time and on different Web Hosts I get --Index of /-- instead of the site loading properly. It's as if the server or browser is looking for an 'index' file instead of being routed through the MVC folders to the proper start up page. I've done everything I believe I am suppose to do as far bring all my dll 'system' files to the 'bin' folder as well as everything else including getting a Web Host that has MVC supporting server but I still keep getting 'Index of /' and the folders instead of the site. Can anyone help? I'm really in a spot. I've been working on this site for months and I need to get it up and running.
Thanks, Rob
It looks like your default route is not setup or the setup is pointed to a place that doesn't exist. Your default route will be in the default.asax.cs page (MVC4 is App_Start/RouteConfig.cs) and looks something like this:
routes.MapRoute(
"Default", // Route name
"", // URL with parameters
new { controller = "Home", action = "Index"} // Parameter defaults
);
So the the Default action is Home/Index. You can change this if you want to redirect to a different default page.

Resources