Codeigniter Controller class login form : 404 page not found - .htaccess

Im trying to combine several tutorials about Codeigniter and bootstrap and understand per codes so i can integrate it in my project. What i am trying to do right now is create a login form using the two framework.
And i setup my View according to the turotial included in Codeigniter 'user_guide/tutorial/static_pages.html' which my landing page is named as 'home.php' is inside the folder 'pages' and header.php, and footer.php is inside the 'templates' folder. I created also a controller: Page.php.
I also use .htaccess to hide 'index.php'. Now i follow this tutorial how to create a login page:
http://learnjquerybootstrap.blogspot.com/2015/01/login-session-using-codeigniter-and-bootstrap.html?m=1
-the only difference is this since i use htaccess:
<?php echo form_open(clogin/index); ?>
But when I try to submit the page i receive a: 404 page not found.
My navbar links are working fine. I understand that the codeigniter works like this:
http://localhost/myfolder/index.php/class/function/
so when i submit my form the url that show up is:
http://localhost/myfolder/clogin/index
and gives me: 404 page not found.
Question:
What is wrong with it?
is there something wrong with the tutorial that i am using? i check other tutorials and the controller structure is just the same, like on this link:
http://www.kodingmadesimple.com/2014/08/how-to-create-login-form-codeigniter-mysql-twitter-bootstrap.html
do i need to include clogin.php in route.php?
or is it about the htaccess? my
uri_protocol
is configured as
'REQUEST_URI'
in config.php. i tried other options but still the same.

Don't need include to route.
I recommented ready auth library.
If you use DevTools in your browser maybe "Network" tab of devtools can help you to why you get 404 error.

i already firgured it out.The mistake was in the route.php, since i tried to combine two examples.. i realized that the wildcard route that i included from the Codeigniter user guide will not work with the Clogin.php.
Since it was set as
$route['(:any)']='pages/view/$1';
So the url works as
http://localhost/myfolder/pages/view/clogin
instead of
http://localhost/myfolder/clogin.
I removed it and now it is working.

Related

Google Site Verification Failure - HTML File Upload method

I have an Express/NodeJS app running on Google App Engine, for which I have the URL in the format of:
project-name.appspot.com, where project-name: My google project name
Now, for site verification, I am using HTML File Upload method.
I am serving the html verification file provided by google as follows:
res.sendFile(path.join(__dirname, path_to_html_file))
Now, when I enter the url: https://project-name.appspot.com/, I can view the file.
Also, the file has the same name as provided by Google.
However, when I click Verify in Webmaster, it still fails with error message "File not Found"
Can anyone point what I might be doing incorrectly ?
You need to serve this file from the /xxxxx.html url, not the root url.
In other words, it needs to be accessed from https://project-name.appspot.com/xxxxxxxx.html
Think about it... This file must stay up for as long as you want to be verified, so it doesn't make sense to be shown at the root url.
Also, make sure there are no redirects in serving this file.

Showing a notice when site fails to load completely

Sometimes during overload some sites fail to load.
I can detect this error using chrome.webRequest.onErrorOccurred api.
I guess the content script will not run at all in this case so sending message from background page to content script is of no use.
How can I paste a notice in the site body that it has failed to load?
Maybe using script execute from the background page? Will the page have a body content?
You've got a few options here. If you're using chrome.webRequest.onErrorOccurred() though I'd suggest you redirect the tab to an error page when an error occurs, using chrome.tabs.update().
For example:
chrome.webRequest.onErrorOccurred.addListener(function(details)
{
chrome.tabs.update(details.tabId, {url: "URL FOR AN ERROR PAGE"});
},
{types: ["main_frame"]});
This will redirect the tab the error occurred in when a web request with a resourceType of main_frame errors.
There are a few things you need to consider here. Do you only want to capture errors from requests with a type of main_frame? If not, just remove the 'types' filter from the event.
The other thing you need to consider is what page you're redirecting to. You can package a HTML file within your extension and then redirect to that. To generate the URL of your error page you can run chrome.extension.getURL('customerrorpage.html').

NodeJS Get Completely Rendered HTML Page

I want to get a html page content from a url using NodeJS after JavaScript is fully loaded and the page is completely rendered, or get the basic html then run all JavaScript files to achieve final content.
For example let's assume there is a website based on AngularJS, so the basic html is simple, but after loading all JavaScript codes in the page, page content is completely different. I want to get that final content on my server to find something in it. Any ideas?
After-Load is a NodeJS package that works like a charm :
var afterLoad=require('after-load');
then :
afterLoad('http://stackoverflow.com/questions/29366718',function(html){
console.log(html.indexOf('charm')>0);
//true
})
Maybe it's too late, but back in the day, PhantomJS solved my problem.

Routes in Codeigniter

I want to have a clean URL in CodeIgniter based application for User's Profile Information.
Please Take a look at URL formats below.
Actual URL : http://www.mydomain.com/index.php/users/profile/user1
I'm expecting users to have Personal URL's like
http://www.mydomain.com/user1
http://www.mydomain.com/user2
http://www.mydomain.com/user3
URL http://www.mydomain.com/user1 should process http://www.mydomain.com/index.php/users/profile/user1 in background execution.
I will be removing index.php from URL using Route library.
Thanks in advance for any sort of help.
Have a look at https://www.codeigniter.com/user_guide/general/routing.html.
$route['user(:num)'] = "users/profile/user/$1";
If you mean you want /anyusername to route to the users controller, you would have to put:
$route['(:any)'] = "users/profile/$1";
At the bottom of routes.php and every non user-URL above it. Otherwise every URL would be routed there, obviously. You will need to implement some mechanism in the users-controller to throw 404-errors, since you are routing all requests not catched in the routing rules above.
IN config/routes.php
add this line
$route['user(:num)'] = "users/profile/$1";

setting redirect page for my Joomla website hosted in IIS

I am using Joomla with IIS in my website, and now i am trying to set a 404 redirect page in my Joomla website, i could use htaccess to make this when i am using apache, but for this IIS its gets tricky it seems.
you can see my web.config file here
any suggestion would be helpful..
There is no module available AFAIK - at least not for 1.6. But it is quite easy to do by yourself. You can use the solution in the joomla documentation. This is usable for any error code.
http://docs.joomla.org/Creating_a_Custom_404_Error_Page
if (($this->error->code) == '404') {
header('Location: /search');
exit;
}
The part behind the Location: is where you redirect to the page you want. e.g. /search in this case. The above is for 1.5, for 1.6 you need to use this:
if ($this->error->getCode() == '404') {
header('Location: /search');
exit;
} ;
in your IIS Console, right click on the website, goto the Custom Errors TAB,
scroll down to HTTP Error 404, Edit Properties, change the Message Type
to URL, and then type in the URL you want to change to.

Resources