I am trying to learn fuelPHP and I came form a CI background. I am using this tutorial so that I can familiarize myself on this.
http://net.tutsplus.com/tutorials/php/getting-started-with-the-fuel-php-framework/
My problem is in step 2. When I access my simple controller
http://localhost/fuel/public/index.php/hello
I get a 404 error.
*fuel is the directory of this freshly installed fuelPHP on my localhost.
When I set this to be my default route, the controller works.
Did something change in the new version that prompted this?
Here is my .htaccess on the /public/ folder.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Thanks.
You are making it very complicated for yourself by installing FuelPHP like this.
It has been designed in such a way that the 'public' folder is your webservers document root, which means all fuel stuff is outside your document root, and the .htaccess is directly inside your document root.
By not only installing it entirely inside your document root, but also in a subfolder of that document root, you need to modify your rewrite rules. Start by adding
RewriteBase /fuel/public
to the one in public, and see if that helps. Also, this .htaccess is made for "standard" apache type installations. If you run anything else you might need a different .htaccess. If you use fcgi for example, get the .htaccess from the 1.4/develop repo, it's more fault tolerant towards your webserver type.
Final remark: you should not use localhost as hostname. It's an illegal name in a lot of RFC's, one of them being the one that documents the use of cookies. You'll have all kinds of session issues with some browser (versions) if you use "localhost". Instead, setup virtual hosts (a better solution then subfolders anyway), and use a hostname like "mymachine.local".
Related
I want to install my ZF2 application on a VPS server without support for Virtual Host. I´m using a simple application based on ZendApplicationSkeleton.
I´m using the default .htaccess:
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
All solution I´ve found in SO does not work for me. They may fit ZF1, but not ZF2:
Link 1
Link 2
Link 3
Link 4
My application is in a folder named /var/www/html/testapp.
The main page is loaded once I typelocalhost/testapp/public on the browser. Also my module is loaded if I type localhost/testapp/module, but navigation does not work.
Ie: in the main page, I´ve created a button like:
Go To Module
But if I click on it I navigate to localhost/login/index showing Not Found, not to the correct module/index.phtml page.
Help appreciated with that.
Your problem has nothing to do with server configuration. Since your app is in a sub-folder, the link is wrong. It would need to be something like
Go To Module
for it to work. However, public/ should never appear in you URLs. With things setup this way you are allowing users to view files outside your app's web root, which is a potential security risk (and results in ugly URLs).
The solution to this is to setup a separate vhost for your ZF2 app, which has a DOCUMENT ROOT pointing at the app's public folder. If you are having problems with this, post that as your question; or if you can explain why this isn't possible perhaps we can advise further.
I have recently completed my first laravel site, but now I am stuck with deployment. This is an entirely new concept for me. My webspace is supplied by 1&1.
I have attempted several tutorials, but none seem to work.
Based on the tutorial here at:
Uploading Laravel Project onto Web Server
I structured my server folders like so:
(note when first FTPing my server, there was no www or html_docs, only a logs folder).
In the www, my index.php was altered to:
require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/start.php';
In the laravel/bootstrap/paths.php file I altered:
'public' => __DIR__.'/../../www',
When visiting my domain in a browser, for example: myDomain.co.uk - the site is redirected to a "placeholder" (named /defaultsite) page for 1&1 domains and states "This domain name has just been registered."
If I append /www/index.php for example, I get file does not exist, even though the file is residing in my structure above.
As you probably noticed I am very new to server side aspects such as FTPing ect. I have read a few tuts, and all seem to take a different approach, leaving me confused to the best method.
I am not sure where to go from here, so any advice is appreciated. Thank you.
Edit:
I think I actually got it working, but now when I go to domain.com/public I get what I think is a DB error:
SQLSTATE[HY000] [2002] No such file or directory.
Any Advice please?
The reason you are seeing /public/index.php is because you are pointing to the top level directory and not the /public directory. To fix this go to:
Manage domains
Expand your domain and click "Edit Destination"
Change the destination directory to /public/.
This should remove public from the URL.
This is the .htaccess file I use for 1and1 and laravel 4.2 and it removes .index.php and also uses an updated version of PHP:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
AddHandler x-mapp-php6 .php
AddType x-mapp-php6 .php
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]
</IfModule>
All fixed :) turns out 1&1 do not host their db name as local host, or 121.0.0.1. I simply changed the details and works a dream. next step is to get rid of the terrible /public/index url.
I have an application written in Codeigniter 2.1.4 which works on my local machine installed with WAMP.
When moving the project over onto a production server, Codeigniter routing stops working. The login form actions a controller method, but instead I get routed to the home page of the website. The same happens if I manually try to enter any part of the web app, even though I have redirect logic for not being logged in to the app.
My production server has IIS6 installed and IsapiRewrite4.
I've tried copying all the rewrite rules from the .htaccess file that comes with CodeIgniter into an IIRF.INI file but I just can't get it to work.
These are the default .htaccess rules:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
I've read that you can paste that into an IIRF.INI file and it should work but had no luck with it.
Also, I'm not exactly sure where to put the IIRF.INI file, I was guessing at the CodeIgniter root directory where the other .htaccess is.
I also noticed that there are other .htaccess files, one in the /core folder, one in the /application folder, and one in the /application/cache folder.
Do I need to restart IIS on the production server when changing/adding IIRF.INI files?
I've also tried the rules suggested here with no luck: Configure htaccess to work with IIRF on IIS6 - codeigniter
Can anyone help??? Maybe it's not even a Rewrite Issue, I'm not sure... Please let me know if you need any other information.
Isapi Rewrite is a product by Helicon Tech. Helicon products use slightly different configuration files to Ionic IIRF isapi rewrite module which uses the IIRF.ini files. I think you've got your products mixed up.
See Helicon's documentation at http://www.helicontech.com/isapi_rewrite/
Alternatively Ionic ISAPI rewrite module is available at https://iirf.codeplex.com/
I'm working on a project using Cloud9 IDE, running PHP5 on Apache 2.0. I'm primarily a front-end developer, but I have decent experience with PHP. I'm familiar with MVC frameworks, and to a lesser degree, this functionality is what I'm trying to emulate, but simpler. I tried implementing CakePHP, but found it was a little too robust for what I needed -- I don't want a backend-heavy setup. I want to write some custom sort of routing mechanism for my application.
Ideally, I would like every request to my site to come through one page (this custom "Controller"), and from there I can write my own logic to figure out the appropriate templates, http codes, errors, etc., to include. My question is, how do I make this happen? In other words, how do I make a request to http://mysite.c9.io/user/view/2 get channeled through http://mysite.c9.io/index.php , and not try to request the /user/view/2 directory on my server?
I'm vaguely familiar with mod_rewrite and .htaccess rules, but I suspect they may play a role here.
First make sure that mod_rewrite is enabled. Check your httpd.conf file for
LoadModule rewrite_module modules/mod_rewrite.so
Make sure it's not disabled with a # in front of it. Next change the root <Directory> settings to
<Directory />
Options All
AllowOverride All
</Directory>
Make sure you change all the occurrences of AllowOverride None to All. Then restart Apache.
Now that mod_rewrite is enabled, add this to an .htaccess file in your web root / directory
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d # not a dir
RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteRule ^ index.php [L]
This makes sure that every request that otherwise would have been a 404 (which means it excludes images, css, js etc.) now routes through the front controller index.php. Some, content management systems like to add another %{REQUEST_URI} check to make sure index.php is only invoked to process the kind of requests the framework actually expects.
Joomla, for example, adds the following:
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf))$ [NC]
I have looked at several examples of htaccess configs for websites within sub-directories, and tried most of them without 100% success.
My setup is:
using Yii framework
htaccess at public_html/.htaccess
site located inside public_html/mysite directory
index handling all requests located at public_html/mysite/frontend/www/index.php
The status of the URLs:
www.mysite.com works fine [ok]
www.mysite.com/controller/action shows me the homepage [wrong]
www.mysite.com/mysite/frontend/www/controller/action works fine [wrong, the item above should work instead]
My .htaccess at the moment looks like this:
AddHandler application/x-httpd-php53s .php .html
Options +SymLinksIfOwnerMatch
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteCond %{REQUEST_URI} !^/mysite/frontend/www
RewriteRule ^(.*)?$ /mysite/frontend/www/index.php [L]
I have tried everything, but I have no idea why www.mysite.com/controller/action won't work :(
Any help would be really appreciated! Thanks!
I found the answer to this similar question to be helpful. Here is how my rewrite rules ended up:
#Forward all non-existent files/directories to Yii
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) subdir/index.php/$1 [QSA,L]
This takes all non-existent files/folders and sends them to the yii script with initial url appended. QSA appends any query string that may be present in the initial url.
You didn't mention if you configured Yii's Url Manager for clean URLs. You need to, otherwise Yii expects the "route" to appear as a GET param named "r". If you didn't, consult this section of the definitive guide
You dont need to edit .htaccess. You just need to move the Yii entry script (index.php) and the default .htaccess up from the subdirectory to the webroot (so that they reside directly under public_html). Once you move index.php and .htaccess to the root directory, all web requests will be routed directly to index.php (rather than to the subdirectory), thus eliminating the /subdirectory part of the url.
After you move the files, you will need to edit index.php to update the references to the yii.php file (under the Yii framework directory) as well as the Yii config file (main.php). Lastly, you will need to move the assets directory to directly the webroot, since by default, Yii expects the assets directory to be located in the same location as the entry script).
That should be all you need to do, but if you need more details, I describe the approach fully here:
http://muhammadatt.tumblr.com/post/83149364519/modifying-a-yii-application-to-run-from-a-subdirectory
I also didn't update the .htaccess file, easier to modify the httpd.conf virtual host for the subdomain and change the DocumentRoot to point to your yii folder.