Symfony2 MobileDetectBundle redirect is not working - php

I'm making a mobile version of my site using MobileDetectBundle.
I'm trying to make a redirection to a mobile site like in the usage example. My config.yml is a copy/paste of what's in the readme.
mobile_detect:
redirect:
mobile:
is_enabled: true
host: http://mobilesite.local
status_code: 301
action: redirect
tablet: ~
switch_device_view: ~
But when I hit http://website.local nothing happens. I'm using User Agent Switcher Firefox extension to appear as a mobile browser.
The bundle seems well configured because when I use is_mobile() twig helper it detects me as a mobile.
Any idea? Thanks in advance.
Guillaume

Thanks to erlangb I found the answer. Switching the user agent of the browser is not enough.
MobileDetectBundle creates a cookie named device_view so you have to remove this cookie to switch and appear as a mobile.

Have you followed the guide correctly?
From README
"Now when you hit to http ://site.com you are redirected to http: //m.site.com. At this point if the http://m.site.com is configured to point to your project you will get circular reference error. To get rid of the circular reference error we want to disable mobile redirecting when we land on our mobile site."
You have to configure the mobile environment by following the steps 2 and 3 of MobileDetectBundle

Related

Why is the auth/login path returning 404 error?

I am new to Codeigniter and I have recently started a project using Codeigniter v3.10 and the Ion-Auth library for user actions.
When I try to access the login page base_url/auth/login I get a 404 error.How can I troublehsoot/solve this? I don't see anything in my network tab in the browser.
I copied and configured the files as presented in user docs.
Thank you in advance
base_url/index.php/auth/login
or use .htaccess to remove index.php

Redirect to Laravel framework page

I need to redirect from a CGI to a page of the same server created in Laravel. When I use the path from a browser it presents itself without problems, but when using the CGI, Laravel presents an error to me.
https://myserver:8080/bitacora/index.php/devices
Error when using Location: /bitacora/index.php/devices header from a CGI
The only difference I see in PHP is that it does not use QUERY_STRING, but the "arguments" are delivered by the PHP_SELF variable.
Any ideas on how to act correctly? I remember that some frameworks redirect to a variable, such as module or action. Something similar in Laravel?
Use full URL
not just
Location: /bitacora/index.php/devices
But replace this with following
Location: http://myserver:8080/bitacora/index.php/devices.

"You cannot access this page directly" - Hybrid Auth

I'm hosting my PHP Yii application on AWS Elastic Beanstalk and hence using the database to store sessions. I've successfully implemented facebook login using Hybridauth on a shared hosting environment. When I host on Elastic Beanstalk facebook login gives the error:
"You cannot access this page directly"
The URL ends up as:
http://mydomain.com/hybridauth/default/callback?hauth.start=Facebook&hauth.time=1393106016
I've learnt from here that this is related to facebook calling back to the application but finding a different session. Endpoint.php then throws the error:
# Init Hybrid_Auth
try {
// Check if Hybrid_Auth session already exist
if ( ! isset( $_SESSION["HA::CONFIG"] ) ) {
header( "HTTP/1.0 404 Not Found" );
die( "You cannot access this page directly." );
}
How can I ensure facebook calls back to the same session and successfully signs in with hybridauth?
Its due to PHP SESSION name
If you have change session name in confing file of Yii. Then you have to use add this session_name('samar_v4'); in file protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php in starting of functoin authInit
Check your Facebook application's redirect URL. Facebook doesn't allow multiple redirect URLs. So each time you change your hosting/domain/address, you'll have to reconfigure the Facebook application's redirect URL or use a different set of credential.
Also your redirect URL should be something like this: http://mydomain.com/hybridauth/?hauth.done=Facebook
This worked for me as well:
"base_url" => "https://example.com/inc/hybridauth/",
I changed it to
"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",
For me it worked on the main domain but not on a subdomain. I worked out it was the base_url in config.php that caused the error.
Instead of
"base_url" => "https://mydomain.com/inc/hybridauth/",
I changed it to
"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",
Now it works anywhere I put it.
For anyone else struggling with this issue, and its not related to the www-domain registration issue, my problem had to do with not being able to write to the php session directory. Not sure how or when it was altered, but if you cannot write to /var/lib/php/5.5/session, hybridauth will not work.
As per the other answers, I believe this is a session problem, perhaps the session is started under the wrong domain and then cannot be re-fetched under the other domain.
I solved this by removing various ServerAlias settings from my development Apache config.
this 'caused' the error:
ServerName mydomain.com.au.localhost
ServerAlias www.mydomain.com.au.localhost
ServerAlias localhost.mydomain.com.au # << using this one
this fixed the error:
#ServerName mydomain.com.au.localhost
#ServerAlias www.mydomain.com.au.localhost
ServerName localhost.mydomain.com.au # << using this one
apachectl restart
(I normally use mydomain.com.au.localhost so I'm leaving them in for later use.)
I had the same issue using Hybrid Auth 2.8. It relates to our custom session handler which is set by session_set_save_handler().
Hybrid Auth uses standard PHP sessions, so after redirecting and opening a new session, Hybrid Auth starts using standard PHP file sessions instead of your custom session handler. This result in the loss of config data from our session and getting this error message.
I resolved this issue by adding our own custom session handler at the top of hybridauth/index.php (located in the same dir as config.php and live.php).
This forces Hybrid Auth to use your custom session handler.
I found this problem that seems unsolvable. I was giving up, that's when my instinct led me to do a test and voila everything working.
For anyone with the same problem have a question: The file that calls the API is in the same directory it?
  Me only worked when I put my file in the same folder as the config.php file. Try it there and tell me if it works!
A hug
and Greetings to all!
I solved my particular HybridAuth "You cannot access this page directly" error with the domain name on the session cookie. My app exists on a subdomain and I'd designed the redirect to point to socialize.sub.domain.tld, and the cookie wasn't reaching the _Endpoint.
Changing the session domain to .domain.tld solved it. - Hope this helps :)

Magento helloworld tutorial

We're working on Alan Storm's tutorial: Magento Controller Dispatch and Hello World on Magento 1.5.0.0.
at the step:
Clear your config cache, and load the following URL
http://exmaple.com/helloworld/index/index
and it produces a page not found error, as follows:
Whoops, our bad...
The page you requested was not found, and we have a fine guess why.
If you typed the URL directly, please make sure the spelling is correct.
If you clicked on a link to get here, the link is outdated.
Two of us are working on this. One of us on a Linux platform, the second on Mac OS X 10.6.7. The same "page not found" error on both platforms. We both have double-checked each other's tutorial code by comparison to Alan's article. It seems that something is remiss in the tutorial code in that it would not work on two independent platforms.
What is the best way to move ahead with debugging something like this?
First check the module is active, at the very least it should appear in System > Configuration > Advanced > Disable Module's Output or use Alan's Module List.
Next, double check for typos in the controller class and pay particular attention to the case. In the config frontname should be frontName (a capital N is often overlooked).
I had the same problem , Double check your /path/to/magento/app/etc/modules/Module_Name.xml , I had the codePool set to "community" and placed my extension in "local" directory this caused the 404 issue, when I changed the codePool value to "local" everything worked
example.com (or exmaple.com as typo'd in the tutorial) is a placeholder link used in documents. You are supposed to replace it with your own hostname, i.e. if you are developing on a local webserver http://localhost/, like this: http://localhost/helloworld/index/index
Just stumbled over the same problem and found the solution to be that mod_rewrite has to be enabled on the server for the URL given in the tutorial to work. Elsewise, it will work with the following URL as well:
http://exmaple.com/index.php/helloworld/index/index
try by adding "index.php" in your url.
For example: http://example.com/index.php/helloworld/index/index
If you are done with this. Search some article to remove index.php from magento.
I am on magento 1.8 and i fixed my 404 error by doing the following. inside Magentotutorial_Helloworld.xml they tell you to put this code in "local" since i do not have a local folder i put mine into the community folder. Change the code to this and it will work. "community"

codeigniter installation problem on shared host

my host account is something like:
~
~/public_html
~/public_html/system/application
to access my web, I need to put http://example.com/~userid in address bar
I install codeigniter in the ~/public_html directory, I can access http://example.com/~userid.
The Welcome page shows correctly, and the related user guide pages show correctly.
The problem is: if I create a new controller, and create new views, the web page just show "Error 404: Document Not Found". If I use http://example.com/~userid/welcome/index it has the same problem.
If I use base_url() function it shows http://example.com/~userid/
What should I do do fix this problem?
Thanks in advance!
Try http://example.com/~userid/index.php/welcome/index.
It looks like your URL rewriting is not set up or badly configured. This is the default way if URL rewriting is disabled.
EDIT See this page of the user guide, especially the section "Removing the index.php file" on how to set up URL rewriting.

Categories