I created my own login page and social media (Facebook) with Codeigniter 2.1.2, then I wanted to use url redirect, for example:
http://mydomain.com/account/login/redirect_url/login/http://mydomain.com/
1- redirect_url // is a Method in account controllers
2- login // parameter define login or logout,when click link login/logout
3- http://mydomain.com/ // Is the url for redirecting to, after login succeed.
In my localhost it's working well, but on my server it's not working. I know some reasons why does it work, because of .htaccess file
Local:
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Server:
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
I think that, cause by Question mark(?), Even facebook login is not working also. But I tried the code without ? on the server, but it doesn't work at all, if I use ? works all, but url only.
My question is what should I do with this code?
I have noticed that many CodeIgniter developers are not using the standard method that many sites use today.
Try this:
RewriteRule ^ index.php [L, QSA]
In essence, you'll find that there are many ways to do it, but I don't think that you really need to use the ./ and the $1.
I guess it also depends on what server system you are using.
Hope this helps. If not, perhaps you could show us your entire hypertext access file (.htaccess)?
Related
I have iframe based facebook app, I just want to do is that whenever someone hits the application url directly http://mysite.com must be redirect to my facebook canvas url for this app say http://apps.facebook.com/mysite. This seems pretty easy but unfortunately its not clicking in my mind
any help would be appreciated
EDIT
the application is in codeigniter
EDIT
htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
php_value error_reporting 7
php_flag display_errors On
php_value auto_prepend_file prepend.php
say my domain is
http://abc.com/mysitefolder
my facebook app link is
http://apps.facebook.com/myappname
please consider http and https conversion too
also guyz one suggestion too as you see am using prepend in htaccess its just to get the user timezone for some date time stuff, is this fine am using it this way? the file actually sets a cookie for a user on very first visit to the site per session
Best Regards
Junaid
Any canvas page for an app that comes from Facebook will have $_REQUEST['signed_request'] defined. You could check for the existence of this request variable and if it is not set, redirect to Facebook.
well as far as i know there isn't any server side coding to do so... then again how could there be since it's all happening on the frontside of things what you could do is using javascript like so
if(window!=window.top){i am iframed now redirect or w/e you wanna do}
Since you want to redirect the domain name to the app, not the other way around, the fact that the app is in an iFrame isn't relevant.
The best way to do it is using .htaccess, in my opinion. This means that you can use custom URLs such as mydomainname.com/mypagename/, which would redirect to apps.facebook.com/myappname/mypagename/, so you can advertise your app easier. Another benefit is that you don't have to rely on Javascript. Some people (very small amount) have it turned off, but why parse all the PHP code to do it?
So, what you can do is have the root domain "blank" and only include the following in your .htaccess file:
RewriteEngine on
RewriteRule ^$ http://www.mydomainname.com/ [R=301,L,QSA]
RewriteRule ^/(.*) http://www.mydomainname.com/$1 [R=301,L,QSA]
QSA will also attach query parameters to the destination URL, such as "?ref=email".
Of course, if you keep the app code on the same domain, in the root, you don't really need to do anything, just tweak your authentification code.
If this doesn't work for you, please give us more details:
Where does the app "live"
If the app sits in the mydomainname.com, what happens when you access the URL directly?
How do you do the authentification?
Code helps, obviously.
Unless mydomainname.com isn't specific for the app, I'd recommend hosting the actual app on a subdomain. Actually, regardless, should help you organize. Or you might want to make the app accesibile as a website as well, with a Facebook login option.
Cheers
We have two sites, and we've just now made an in-house development server that we want to have both sites on. What I want to accomplish is to have an .htaccess in each of the site folders that prepends the development URL of the site. For example, where they simply have a header(location: /folder/whatever.php), the files should actually go to thesite/folder/whatever.php.
Currently what happens is (for example) they'll go to 192.168.x.x/folder/whatever.php
If I understood correctly and what you want is to redirect 192.168.x.x/folder/whatever.php to thesite/folder/whatever.php, you could use this:
RewriteCond %{HTTP_HOST} !^thesite.com$
RewriteRule ^(.*)$ http://thesite.com/$1 [R=301,L]
I have tested my website on my localhost and it is working fine and all the views/controllers and models are tested.
So I thought I would put it on my webserver and test it there, the website displays however when doing functions like
For example registering or loging into the website does not work:
I checked in firebug it is saying
500 Internal server error
Here is my site, please could you have a browse through the pages , even try registering if you like.
Another thing I noticed on the failed pages is that my favicon is changing to the root domains favicon.
Here is my actual website, its in a sub domain.
Could it be my htacces
Here is the code in it:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
I dont understand why It works on my localhost but not on a dedicated server.
They were both Apache windows servers.
Thanks, for your time.
I think the problem is with your routes. All your pages are with in the domain
http://www.iiios.eu/midas/site/register
But on registering or login it goes to
http://www.iiios.eu/midas/register
without the site in the middle and CI doesnt know how to transfer control to the route. You might wanna check your forms open and action atr for register and login form.
Update
This is your form tag. Check whether you have the method create_member on register class which is in midas directory. My guess is that you have accidentally missed the site there.
I think it should have been
"http://www.iiios.eu/midas/site/register/create_member"
This might be a problem with the routing, see if the referencing to the routes, like when registering, are correct or if you defined routes in the config.php. Is the base_url() defined correctly? Also on the homepage in the sidebar you reference a non-object property.
my website has a log in by open id feature. When a user logs in for the first time using his/ her openid they are redirected to a create account page. I noticed just recently that one user when logged in using her google account created an account for the first time. However when she tried to log in again using the same google account - she was faced with creating a new account again. I checked the db and saw that although she used the same google account - the open ID urls which were retrieved are different?
EDIT===================
Thanks Kobi for the information - the issue is that I need to set up my website so it always opens with www prepended to it i.e. http://www.mysite.com and NOT http://mysite.com
Owing to this subtle difference google OpenID recognises the two urls as different urls!!! Help please
I realised its an htaccess thing however I googled a bit and found these htaccess commands:
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule (.*) http://www.site.com/$1 [L,R=301]
However the problem is that when I use this in my htaccess it does forward and ensure the link reads as www.site.com however it messed up all the javascript links - actually I'm using url rewriting here as well... my whole htaccessfile is somewhat like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
AddType text/css .css
inclusion of the two lines messes up the url rewriting :( what do I do here
======================
Uh never mind I figured it out :) I was putting the two rewrite url lines at the end thus somehow overriding the other rewrite rules - putting them in the beginning fixed it :) thanks anyway
Google gives different URLs for different domains.
It is possible your user used a different URL each time to log in? Even www on the start of the url can change the code Google returns.
I'm writing my own url shortener. I'm done with everything such as creating short urls. But when I try to browse htt p://example.com/rtr93, I get a 404 error. But http://example.com/index.php/rtr93 works find and shows the relevant page (I'm not redirecting to a new url. I'm just getting the relevant record from database which has a column short_url).
I'm using PHP and syfmony 1.2 if that helps. I think I need to properly setup .htaccess file. But I don't know where to get started.
Something like this should work:
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ /index.php [L]
You may want to make the regex more specific if you're planning on hosting other things on the same domain.