'404 Page Not Found' every page with codeigniter - php

I used this .htaccess file on my localhost:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
But when I uploaded my site to the ftp, it suddenly doesn't work. I set the base_url. Mod rewrite is enabled. What else can be the problem. My knowledge is very limited, I was already happy, that I programming part, but this server stuff is over my head. But I'm willing to learn it, so if you recommend a place to start, I'm open to that.
So right now only a formatted page comes in, with basic css settings and the 404 message. It's weird, that this message can be created in a form like that, so it means it's not a technical problem, but a settings problem. I googled around, tried more .htaccess files, but nothing works. Thanks for your help!

This is silly. The controllers must be named starting with a big case letter. So the only problem was, that I named my default controller as welcome.php instead of Welcome.php. It was hard to figure out, because it worked on localhost. So this had nothing to do with .htaccess at all. May be valuable to others, so they don't make the same mistake.

I have seen this error when people are using FastCGI - you need to add to the config.php:
$config['uri_protocol'] = "REQUEST_URI";
This clicks everything together - Might not be the answer to this issue but worth a try and others with your symptoms may find this useful.
Thanks,
//P

Related

Is Absolute Paths the only solution for htaccess URL Rewrite Issues?

So im trying to do something simple, just want to change the urls like for example:
website.com/user?slug=usernameexample to website.com/user/usernameexample and I used the code below:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?user/([^/d]+)/?$ user.php?slug=$1 [L,QSA]
Seems simple but for my surprise this is a little nightmare because in the url website.com/user/usernameexample all files like css/js and others will not work because will try to open inside the directory "user" And thats not all... Also all links and files will try to the same, so for example login.php will also try to open inside the "user" folder that does not exist...
After reading many stackoverflow answers seems that the most common answer is "Absolute Paths" or <base href="http://www.example.com/" />... However The "base href" answer don't really works properly because that brings other issues... So seems that "Absolute Paths" are the only viable answer?
I wonder If there is another solution... I did tried some small htaccess changes but they did not worked with me...
Yes, Absolute Paths are the only viable answer.

php file not accessible when url typed in to browser

I tried to search for this on the forums, but I don't know exactly what my issue is called. I hope this isn't redundant to another forum or a really stupid question. This is also my first post, so I read through what I need to put in this question, but please help me learn if I forgot to include something.
I FTPed a .php file over to my server into the /public_html folder which is where my index.php file are as well as everything else that I can get to show in my web browser (chrome). The file is named game-response-confirmation.php. I have the permissions for this file set to 777 on the server as well just for testing purposes (i'd like to set them back to 644 when I'm done if that doesn't have to do with the issue).
The issue is when I type in the url www.mywebaddress.com/game-response-confirmation.php into the address bar, I receive a 404 Not Found error. It says that the file was not found on this server.
To be honest, I'm not sure what other information you need to help troubleshoot this issue with me. Ask and I will provide more information.
For this, I would expect the page game-response-confirmation.php to appear as a webpage in the browser. Currently, the website is a simple echo since I needed to make sure it wasn't the php file that was creating the problem.
Thank you in advance for any help.
Look at ".htaccess" file. Perhaps there is wrong redirection inside.
For instance:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Third line obtains all URLs and sends them to unknown place. In result you get error #404.
Golka had a great suggestion. going into the .htaccess file gives some information about what is going on. It told me, indirectly, that my host was switching over the server. So I was able to investigate and figure out that they are in the middle of the migration. Because of this, I didn't have the new server information and was uploading the .php page to the old server while the domain was pointed to the new server. So of course this file wasn't available! Silly. Thank you all for suggestions and help.

I need to format my URL using .htaccess file but my script not working

This is my URL
http://www.example.com/details.php?id=12&page=120.v2013-09-18.by.Acme
My htaccess script
RewriteEngine On
RewriteRule ^details/([^/]*)/([^/]*)\.html$ /details.php?id=$1&post=$2 [L]
I need to get my URL to
http://www.example.com/details/12/120.v2013-09-18.by.Acme.html
how can i change my url to above format. Please help me.
You need another rule to redirect old url to pretty URL:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /details\.php\?id=([^\s&]+)&post=([^\s&]+)\s [NC]
RewriteRule ^ /detail/%1/%2? [R=302,L,NE]
RewriteRule ^details/([^/]+)/([^.]+)\.html$ details.php?id=$1&post=$2 [L,QSA,NC]
Someone very smart once said, instead of giving a fish to a hungry man, it is better to teach him how to fish. So I won't give you the exact solution. However, I have few tips for you.
Start with some small and easy snippet from a tutorial, that definitely works. If you can make it work on your server, then you can modify it step by step to your desired form.
If you cannot make it work, make sure, you have mod_rewrite enabled on your server. You can google easily how to do that. However, some hostings might not allow you to do this at all.
It is actually possible to have cool URL even without .htaccess and mod_rewrite. Check this answer out.
Know that there are some already prepared solutions for cool urls, most PHP frameworks has them. Actually, doing any web page without any framework is a pain in the ass. You can try e.g. Laravel (seems to be the most popular one nowadays). I am using Nette and I would never ever do webpage without it again.

Yii framework blank page issue for many times

I am working in yii framework. my site many times problem in blank page issue. i am trying many ways but its not work properly. i am already trying increase maximum execution time. but its not work.its not showing any errors. also trying error_reporting(1);. this error not showing all times.
My htaccess file code is give below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How can i solve this blank page problem. Please guide me.
Yii can't handle fatal error (Yii2 support it by using error_get_last() and register_shutdown_function()).
So you should check you php error log and get the reason.
What about check to see if there are any space before or after the <?php inside view , controller, model file.
i mean at the top of the script, since it will output space, and making the redirect not functioning without showing error.
I had mine solved by found this.
I found one of many the solution for this problem. In my case, there is one Controller that can't be redirected but others is good. All script are good, config and others are good too, then i realize when i "Ctrl + a" on my editor that i have so many "ENTER" and "SPACE" and "TAB" after php closing tag "?>". Then i remove that blank space, that's it my "redirect" is working again. I hope it helps.

Making ExpressionEngine .htaccess allow commenting on index.html

I've got a really quirky issue going on with ExpressionEngine. I've got a live test site here.
Essentially, if you attempt to comment on the index's 'Question of the Day,' you get a proper redirect, but the comment never gets to the database.
If I remove my .htaccess and set the site's index page in my control panel to index.php, then all is well. But with the .htaccess and index.php removed, things go haywire.
Here are the comments of my .htaccess file:
RewriteEngine on
RewriteCond $1 ^(weblog|member|search|site|rss|search|contact|show|commentary|include|about|blog|tags|preview|P[0-9]{2,8}) [NC]
RewriteRule ^(.*)$ /skad/index.php?/$1 [L]
Any tips to troubleshoot this or ideas where I could be going wrong? If it's any help, you can see a screenshot of my folder structure.
Thanks so much for any answers or simply help that you can give.
More: Also, here are headers for a successful post on a blog entry and a failing post on the index.
Update: I did recently find something else strange. With identical backend settings:backend settings http://droplr.com/1sMXc9+
And identical code:identical code http://droplr.com/1sN09A+
I get http://localhost:8888/skad as one form action and http://skadaddlemedia.com/v2/v2/index.php as the other form action.
At this point, I'm completely lost as to what is going on.
the "?" after index.php in the RewriteRule suggests that you are on a server running PHP as a CGI script and thus requires the "forced query strings", correct? This may be ancillary to the problem in the question, but it can complicate things to have this requirement. Looks like you're hosted at Site5... I have no experience with them but you might try the workarounds suggested here: http://expressionengine.com/wiki/Workaround_for_Forced_Query_Strings/
Try changing [L] to [L,QSA] to see if it helps.
I'm not sure but i think that CI and EE are pretty much the same as to the way the htaccess works so this may help you out. It is by a CI guru named Ethan, can't remember the last name, but he is very active in the CI community. Anyway the way that your HTACCESS file is has really been abandoned the new way to do it is a lot easier and you don't have to state your excluded folders it is the best thing since sliced bread for users of MVC or any frameworks i just love it.
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
i can gurentee you that if it is a htaccess issue this bugger will fix it but the bext thing is you dont have to do a thing to it just drop it in and you never have to edit it again i swear by it. so freaking good like fried chicken in the summer yummy!
remember test it first by just dropping it in place of your current one you wont need all that crazy other stuff you got there in yours promise.

Categories