CakePHP URL redirect - cakephp

I have a similar question to the one listed here:
Redirect subdomain to CakePHP action
The difference (I think) is that I have a website hosted on cloud Ubuntu servers and written in CakePHP. What I need to do is redirect:
subdomain.mysite.com --> www.mysite.com/subdomain
I am (no doubt evident from the question) a newbie at these matters, so if changing .htaccess or using mod_proxy etc then please can you explain where to find the files and what code to add (I can navigate around ubuntu, and I have previously used mod_proxy)
Many thanks

Related

Joomla site shows IP address instead of url

I am finalizing my Joomla-site with a Siteground host and encounter the following problem: my site shows the IP-adress instead of the url. Although I type in the url (www.nooitmeerfile.be by the way), it shows the IP-adress.
Could someone please give me a step-by-step explanation on how to fix this? I happen to find a lot of fragmented answers cluttered around the web. I am a novice user, and I'm stuck :-)
Thanks!
Possible steps to debug your issue:
Check configuration.php public $live_site = ''; and try to add your
domain (without trailing slash).
Check if .htaccess file is not altered and try to download and use a fresh copy.
Check if you are using 3rd party sef components / plugins and try to disable them.
Clear your joomla and browser cache.
Contact your hosting provider if something in your hosting is misconfigured.
Hope this helps

how i can disable cakephp Test Suite?

do you test this url in your application that writted with cakephp ?
www.yourCakephpApp.com/test
you see a page like this:
http://www.eliteprojects.org/cake/app/webroot/test.php
how i can disable test suite?
You access CakePHP's built-in test suite's web runner by going to /yourapp/test.php or /test.php, depending on your server's configuration. Going to /test should give you a 404 error unless you specifically added such a route or a file/path named test in your webroot directory.
You can disable the web runner by denying access to it in your server configurations or by simply removing the file. However, there's rarely a reason to do this, as:
A major part of CakePHP's development platform is its comprehensive testing support. It would be like using CakePHP and removing the bake console.
The test runner is designed to be accessible only during development. So unless you're using a debug mode > 0 in production (which you shouldn't be doing), the web runner won't be accessible from that URL.
Lastly, if you're new to Cake, you need to read the Cake cookbook. Start from the first section, and work your way down to the Blog Tutorial. This will answer most of your questions and avoid a lot of common mistakes (such as your misconfiguring your server's docroot and not having URL rewriting set up properly).
Note:
I've bolded the part about the Cookbook because it is such a crucial resource for learning Cake development, and it's the first place you should consult if you run into any problems or have a question. In fact, people get quite annoyed on #cakephp at new users asking the same basic questions that are already answered in the Cookbook—especially if you haven't done the Blog Tutorial.
It should never happens.
After visiting your main web page, it looks like you are running IIS and your server is misconfigured to run CakePHP project. Cake needs mod_rewrite to work but the htaccess is for Apache server only.
While I'm not very sure how to do this, CakePHP documentation did tell you how to achieve this. Checkout the book here:
http://book.cakephp.org/2.0/en/installation/advanced-installation.html#url-rewrites-on-iis7-windows-hosts
Why cant you comment out the contents of test.php and add header("Location: index.php");
??
Simply delete app/webroot/test.php in your production environment.

Joomla Redirect when Download File not Found

I have a website where customers can download msi files. Over time, I retire older version and drop them from my site.
I've noticed that a number of users are following links to the older file paths. When the do, they're seeing the following:
Not Found
The requested URL /files/VBADiff/VBADiff_Professional_Setup_2_0.msi was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I would like to either display my custom 404 message or redirect them to the correct download path. Unfortunately I can't figure out how to do this - I'm a bit surprised that visitors aren't already seeing my 404 message. Can anyone help?
Edit: I'm using version 1.5.11 of Joomla.
File downloads, particularly direct links from an outside referrer do not instantiate the Joomla framework so nothing in Joomla is going to help your problem. Depending on the URLs you are using to get to the files, you will have to fix this issue with either a typical 301 redirect for URLs without query strings or mod_rewrite for those with.
You can use a redirect plugin for joomla 1.5 which also protocalls 404 accesses. I like this one: http://extensions.joomla.org/extensions/site-management/url-redirection/14676

Deploying CakePHP on sub domain redirects to wrong location

I am trying to deploy my locahost CakePHP website to a subdomain. I am able to view the website but it is not working correctly when I try to login or register.
It does not show me any validation error nor does it allow me to login or register and it is landing on the below URL:
subdomain.example.com/webroot/index.php?url=users/login
where it should be something like:
subdomain.example.com/users/login
I am using Go Daddy shared hosting.
The older settings defined at http://bakery.cakephp.org/articles/cguyer/2009/10/18/mod-rewrite-on-godaddy-shared-hosting has solved the issue.
Thank you every one for your help.
This sounds (and looks) like an Apache rewrite issue. There are a couple of things you need to look at:
Check to make sure the .htaccess files are were they are expected. You should have one in the app directory and another in the webroot directory. Sometimes when we compress and/or transfer files to the webserver, the .htaccess files get left behind.
Make sure that the server you are running the site on has rewrite turned on. This may require that you call support at Go Daddy. But my experience is they are always willing to help.
Good luck!

Problem in maintaining session between two different domains on a website done in CakePHP

Well as I have posted earlier too...I have created a site in two languages. One with URL www.mainDomain.com (English) and other with www.fr.subDomain.com (French).
Both are done in CakePHP,in french I have just changed the views of it to French. But the problem is, when anybody login's in English version and then switches to the French version, the session doesn't recognizes it and ask for login again. It has become to be the biggest bug in the Web application which I have done till far.
For that, as Swanny told me to go through a link and I did it on my application as it was said on the link.Apparently,it worked for login which shared session between two domains(main domain and it's subdomain). But when I checked it thoroughly, I recognized that both the sites are throwing the latest NEWS from Database, both data are different. Just to check if I was wrong I changed the some save variable to database in session array. But now it refused to remember anything (session). Could anyone suggest me what could be problem with this and how can I resolve this...???
Thanks in advance
I'm not sure I completely understand, but I'm gonna try. I think this is about a PHP setting called session.cookie_domain.
Assuming your websites have the following URLs:
http://www.example.org/
http://fr.example.org/
http://de.example.org/
The setting you want is: .example.org.
You can adjust this in php.ini, a .htaccess file or even in PHP itself:
<?php ini_set('session.cookie_domain', '.example.org'); ?>
If your websites run on two completely different domains, e.g.:
http://example1.org/
http://example2.org/
... then there is no way to share the cookie between these two different domains.
#dooltaz That is a great solution. Be issue is that cake seems to be setting the cookie after me. What I did instead is send the user ro a redirect method and then move the cookie setting to the afterFilter
function afterFilter() {
if (!empty($this->params['url']['session_key'])) {
// Setup variables here...
setcookie(Configure::read('Session.cookie'), $this->params['url']['session_key'], time()+360000, '/');
// Cakes cookie method will put your cookie name in [] so it does not work.
}
}
(Also fixed typo in your code..)
If you have two different domains, I would suggest the following:
On "www.mainDomain.com", put a link to the "www.fr.subDomain.com" site and pass the cookie in your view file:
$session_cookie = $_COOKIE[Configure::read('Session.cookie')];
echo $html->link('See French Site', 'http://www.fr.subDomain.com/?session_key='.$session_cookie);
Then on the french site add a bit of code to mimic the cookies in the app_controller.php > beforeFilter().
function beforeFilter() {
if(!empty($this->params['url']['session_key']) {
// Setup variables here...
setcookie(Configure::read('Session.cookie'), $session_cookie, time()+360000, '/', $domain);
// You could use CAKE's setcookie command here.
}
}
Now that the cookies match up, you will have to either use database sessions or the cake file based sessions. Read the instructions in core.php to set those up.
This should allow you to basically share the same session over various sites. I'm actually in the middle of implementing ACL over multiple sites with a single login. It can get to be a bit tricky, but just do it step by step, you'll do fine. Also don't be afraid to jump into the Cake core code to see how it works.

Resources