Code igniter - 404 not found, routes issue, ssh server - codeigniter

So first off, I am pretty familiar with codeigniter I've used it for multiple occasions. Right now I have a project too do for school and I installed codeigniter on the server but I am getting routing issues I believe.
So additional info about the server which is different from the normal environment I work with, the server uses SSH and it is very weirdly protected in my opinion. You also need a username and password to view the URL in the first place. (I think it's weird)
If this helps the url is:
https://clipper.encs.concordia.ca/~pyc353_2/
and credentials are (username: pyc353_2, password: FMaqRb)
Now I am able to see any page that I set as my 'default_controller' in the routes, but the problem is trying to go to any other page. Right now I'm trying to access the register controller and I just get 404'd (while it works if I set it as default)
I will link all the code I think may be relevant to the error, hopefully it's not server settings since I have no control over any change.
config.php
$config['base_url'] = 'https://clipper.encs.concordia.ca/~pyc353_2/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
routes.php
$route['default_controller'] = "test";
.htaccess (there may be better code for doing this but I used it in the past no problem and the route doesn't work even if I remove htaccess and add back index.php to 'index_page')
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
So I tried accessing my pagedifferent variations in the url such as: (stackoverflow won't let me post more than 2 physical links)
clipper.encs.concordia.ca/~pyc353_2/register
clipper.encs.concordia.ca/~pyc353_2/index.php/register
neither work although with /index.php/ the error message is: "No input file specified."
So I hope my explanations are clear enough, it's hard to explain something I don't understand the source problem. If you need any additional info feel free to ask. I really need to solve this to proceed at all for my project.
EDIT
I don't know if this is relevant but the 404 message is not even in the codeigniter style it just looks like a plain web 404
Also I am looking at the path on the server and this is the hierarchy: /www/groups/p/py_comp353_2 I don't know if that could affect anything also?
NEWER EDIT
Following what I found here: http://ellislab.com/codeigniter/user-guide/installation/troubleshooting.html
Changing index.php to index.php? (and removing htaccess) actually did make the routing work. Now I am happy enough with this and I can continue working, but being that it's an ugly solve would anyone know how to keep the routing working AND remove the index.php? from my URI?

It appears that your htaccess is not working.
To confirm, create a new PHP file and write this line:
echo phpinfo();
On that page try to search for "mod_rewrite", if it is enabled, you will see it under "Loaded Modules"
It is probable, it is not enabled.
Try this on your server:
a2enmod enable
Then restart the apache server.
For restarting on debian, this should work:
service apache2 restart
For CentOS, this should work:
apachectl restart
That always does not solve the problem.
Even then, try your CI installation in the normal mode after that. (With everything in normal mode: htaccess as before, and no index.php in the URL)
If it does not work, you may need to alter the apache config file httpd.conf
Try to search for this line:
#LoadModule rewrite_module modules/mod_rewrite.so
Uncomment it by removing the # sign
Restart Apache Server.
Test it now, again.
There could still be other things that you could do to enable mod_rewrite.

Related

laravel 5 removing public from url not working on WAMP

Many people post that following htaccess works for removing "public" from url. But i am working on WAMP and this is not working:
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
This shows following Error message from Laravel framework:
Sorry, the page you are looking for could not be found. 1/1 NotFoundHttpException in RouteCollection.php line 161:
There are other methods to remove "public" from url but I want to understand why this method is not working on my side which people followed frequently in their posts. my url is : http://localhost/laravel/ (directory: d:/wamp/www/laravel)
Can any one help me to understand why this popular method is not working on my side? Is their any issue in Laravel internal routing as I think my htaccess is working properly?
Thanks a lot in Advance.
I am sorry this is not exactly what you wanted but... Instead of rewriting the path, go to your Apache config and change your directory so it includes /public as well. That way you will get rid of the now necessary public from the URL. I know it is not an answer to your question, so please do not downvote. Nevertheless, it should solve your problem.
Your router is not picking up the redirected path because your laravel installation is a subdirectory within your webserver and the RewriteRule ^(.*)$ is picking up the whole path which includes /laravel. This is being appended to public/ because it's captured in $1.
The simplest case for you may be to alter the RewriteRule to not capture the laravel directory.
eg:
ReqriteRule ^laravel/(.*)$ public/$1 [L]
You may or may not need a forward slash ^/laravel/(.*)$ ...
Alternatively, (and more correctly) you should setup a virtual host within your apache configuration to serve the laravel application in the root of a virtual host (as it's designed) or you might be better off in the long run using Laravel Homestead as a preconfigured development environment.

Magento Godaddy No file input specified

I have Linux webhosting on Godaddy. I tried installing Magento CE 1.8 on subdomain for more than a week and I still cannot get it to work.
Before you say this question is duplicit, I have tried everything I found on Magento Wiki, Forums, Google and Godaddy forum and support and I still cannot get it to work.
For php5.ini I take Magento php.ini.sample, .htaccess is from Magento too.
Using Options -MultiViews in .htaccess usually doesn't do anything.
Settings cgi.fix_pathinfo = 1 in php5.ini creates cyclic redirect.
I have tried playing with RewriteBase in .htaccess and that didnt help either.
I read that Magento doesnt run on fcgi, so I use in my .htaccess, doesnt help either:
Options +ExecCGI
addhandler x-httpd-php5-cgi .php
I always end up with "No file input specified" or cyclic redirect or server error.
Only lines in error log that I see are added:
[Thu Oct 31 01:23:08 2013] [11988011] [negotiation:error] [client 5.178.58.85:65433] AH00687: Negotiation: discovered file(s) matching request: "path" (None could be negotiated).
But I dont know what that does mean or how to fix that.
So is there anything else I can try or am I missing something? I know Magento on Godaddy shared hosting isnt a good idea, but I need to get there my development running and production will run on my clients Dedicated server.
Add this to your .htaccess file and forgot those other fixes....
RewriteRule ^index.php/(.*)$ [L]
If magento lies in a subdirectory then use:
RewriteRule ^index.php/admin(.*) {RewriteBase}/admin$1 [L]
So I managed to solve it after few weeks of trying different solutions on net and trying to get support to help me.
Nothing helped solve it so I tried myself and found out that the problem is "index.php" in url. So I have created simple php function which is run in at the beginning of index.php file. This function removes "index.php/" from url and redirects to this new url.
Also to remove "index.php" from form actions and other places where the url might show up, it is good to create your own router module or modify Magentos router.
Now it all works.
PS:
I have also kept other fixes in place:
In .htaccess:
Options +ExecCGI
AddHandler x-httpd-php5-cgi .php
AddHandler x-httpd-php5-cgi .php5
Options -MultiViews
RewriteBase /
And in php5.ini
cgi.fix_pathinfo = 1
EDIT
What I wrote does work, but is not good solution, redirect in index.php loses all POST data ofcourse. And looking at Magento and changing router takes too much work, so in the end I managed to create working rule in .htaccess for admin. Just put it as last rewrite rule in your .htaccess:
RewriteRule ^index.php/admin(.*) /admin$1 [L]
EDIT
Forgot to write here, that I have changed the rewrite to this:
RewriteRule ^index.php/(.*) /$1 [L]

how can I get my mod_rewrite to work?

I took a look around at other mod_rewrite questions and couldnt come up with an answer, so if anyone would point me to one that I may be duplicating I would appreciate it.
Anyways my question is: Why is my mod rewrite not working? I followed like 3 tutorials and spent a while reading forums and previous questions on this site, and couldnt get any of them to work. Ive tried doing it through my vhosts.conf file (I think its also known as the httpd.conf on some installations of linux) and through a .htaccess
Here is my .htaccess filed code
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteRule ^/article/([0-9]+)$ article.php?art_id=$1 [NC,L]
Here is the link im trying to get working: mysite.com/article?art_id=$1
To be honest I only have a slight clue as to how mod_rewrite works.
I have mod_rewrite installed (I don't manage the server, but the company I work for also has hosting services, thats how I have access to the vhosts.conf but I did not set the server up, and as far as I know the guy doing it is pro and set it up right)
I put this in to see if I could get it to work and it redirected me to my home page (I think that means its working)
# Options +FollowSymLinks
RewriteEngine on
RewriteRule ^fakepage\.html$ http://yoursite.com/ [R,L]
At least as far as your .htaccess file goes, using the rule you have will not work because the input to the RewriteRule will never have an initial forward slash on it. The rule should instead look more like this:
RewriteRule ^article/([0-9]+)$ article.php?art_id=$1 [NC,L]
However, what you have should have worked when you tried it in a virtual host (assuming you restarted the server), so I'm not sure if this is the actual issue. In what way is the rewrite not working? Are you getting 404 errors instead of being redirected to the file you were expecting?
Tim is correct about the slash at the beginning of your RewriteRule.
When trying to figure out Rewrites, it can be helpful to turn on logging:
RewriteLog "/var/www/mysite.com/rewrite.log"
RewriteLogLevel 9

Advice for Getting mod_rewrite to Work

I am trying to make clean URLs. I have written a simple rule on the .htaccess file and I have been told that it should work. However, it does not. I was wondering if it might have something to so with mod_rewrite not being enabled.
I am using Network Solutions shared hosting. I called the company and was told that mod_rewrite is enabled by default on the hosting I have.
Any advice on how I can check to see if mod_rewrite is enabled? Also, I would appreciate any related advice.
Thanks in advance,
John
EDIT: I just posted this at Serverfault.com, but I'm hesitant to delete it here since I have a feeling it might get more views here. Let me know if I should delete it here as well. Thanks.
EDIT:
Below is my .htaccess file. I am getting a 404 error when I go to a URL that this should re-write.
RewriteEngine On
RewriteRule ^comments/([A-Za-z0-9-]+)-([0-9]+)?$ index.php?submissionid=$2 [NC,L]
Try putting up a bad .htaccess file (i.e. random text) in a test folder. You should get all 500 errors from that folder. If not, .htaccess files are not enabled, and you'll have to get your hosting company to switch them on.
Then try a really simple rewrite rule:
RewriteEngine On
RewriteRule foo index.php
and see if that works. If you get a 500 error at this stage, mod_rewrite is probaby not enabled.

using mod_rewrite to redirect from subdomain to maindomain

My problem is that i have a functioning subdomain (sub.mydomain.com). sub is loaded in mydomain.com/sub.
What i would like to do is to redirect all requests to sub.mydomain.com to mydomain.com.
Somehow it seems that when im the subdomain i cannot access the rootfolder (main domain). I can get it working with from mydomain.com/sub to mydomain.com. But not from the subdomain.
Currently im using:
RewriteEngine on
RewriteRule ^(.*)/?$ /home/web/webuser/$1 [L]
When accessing sub.mydomain.com i get a 500 Internal Server Error.
Is there a restriction in accessing the main from a sub? (rights wise)
Or maybe another way of getting to main, perhaps something like (../$1)
Thanks
EDIT:
I only have access to .htaccess. So DocumentRoot cannot AFAIK be used in .htaccess file.
What about symlinks? I dont really know what it does, but i assume that it links two locations? The only code i found for that enables symlinks (Options +FollowSymlinks) - but this line doesnt say anything about what to link (perhaps im all wrong)
Btw. thanks for input so far !
I must admit that I did not fully understand your question. Do you want to redirect everything from sub.mydomain.com/whatever to mydomain.com/whatever? In that case, the following (put in the config file of your sub.mydomain.com) might work:
RewriteEngine On
RewriteRule ^/(.*)$ http://mydomain.com/$1 [R,L]
It redirects on the client side, meaning that the user will see mydomain.com/sub in the browser.
EDIT: I think I understand your question now. Yes, it's a permissions issue: If the DocumentRoot of your web site is /whatever/sub, then you cannot just access /whatever by adding "/.." to the URL. I hope you understand that this is a good thing. :-) mod_rewrite just changes the URL, so it cannot do that either.
So, to solve your problem, you need to either change the DocumentRoot of sub.mydomain.com or create a symlink that allows you to access the required directory (e.g. /whatever/sub/redir-target -> /whatever). Be careful with the symlink option, though, since it will create valid directories of infinite length on your file system (/whatever/sub/redir-target/sub/redir-target/...) and some scripts cannot cope with that.
EDIT2: Instead of a symlink, you might want to create an alias, e.g., something like this:
Alias /redir-target /home/web/webuser
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/redir-target/.*$
RewriteRule ^/(.*)$ /redir-target/$1
Still, I think the easiest solution is to change the DocumentRoot...
Why not try using a Redirect Directive from mod_alias?
It's difficult to provide a definitive answer without knowing more about your server configuration.
The following might work and is at the very least a decent starting point:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.mydomain\.com
RewriteRule (.*) /$1 [L]
Ideally that would go in your httpd.conf, but might work from a .htaccess file (again, more information about how your subdomains are setup would be helpful).

Resources