Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application templates: missing .htaccess #2800

Closed
alpharder opened this issue Mar 18, 2014 · 18 comments
Closed

Application templates: missing .htaccess #2800

alpharder opened this issue Mar 18, 2014 · 18 comments
Assignees

Comments

@alpharder
Copy link

IMO app templates should contain .htaccess file configured for this:

    'components' => [
        'urlManager'   => [
            'enablePrettyUrl' => true,
            'showScriptName'  => false,
        ],
    ]

So we get out-of-box working routing for Apache HTTPD.

https://github.com/laravel/laravel/blob/master/public/.htaccess

@samdark
Copy link
Member

samdark commented Mar 18, 2014

Probably a good idea.

@alpharder
Copy link
Author

We should decide whether we only include rewrite rules or also any other useful configurations

@samdark
Copy link
Member

samdark commented Mar 18, 2014

What do you mean by useful configurations?

@alpharder
Copy link
Author

We could probably use html5-boilerplate .htaccess file

@SonicGD
Copy link
Contributor

SonicGD commented Mar 19, 2014

Then what about nginx config example? We don't use Apache for years.

@jason-son
Copy link

we'd better use " php -S " to start native Server inside PHP for dev.

@samdark
Copy link
Member

samdark commented Mar 19, 2014

@alphard-code nah, that's too much.

@SonicGD it's in the docs. nginx doesn't read config files from webroot.

@e6nian yeah, I need to add it to docs.

@Sammaye
Copy link

Sammaye commented Mar 19, 2014

@SonicGD Nginx is extremely simple to setup, much simplier than Apache actually and as @samdark says it doesn't actually read config files from inside the webroot.

There is, of course, one downside to .htaccess, it is slow. That is why, on the Apache server we do have, it isn't used since it has to perform a new directory scan every single time, every single request.

I kind of agree with the current setup, adding commented out line to the main.php config for the pretty URLs directing the user to a help page about it.

@klimov-paul
Copy link
Member

Not every web server supports .htaccess. I suppose "out of the box" application examples should not bound to it.

@Ragazzo
Copy link
Contributor

Ragazzo commented Mar 19, 2014

i would like to see this examples in docs like in Yii1 but better, so they will be simple copy-paste and running. Currently examples for example for nginx not working with such settings in yii config.

@samdark
Copy link
Member

samdark commented Mar 19, 2014

@Ragazzo hmm, I'm using the same nginx config it and it works just fine.

@Ragazzo
Copy link
Contributor

Ragazzo commented Mar 19, 2014

it works when you set showScriptName to false ? strange )

@o-rey
Copy link
Contributor

o-rey commented Mar 31, 2014

Maybe .htaccess should be added to Gii, so every person who needs it can create it in one click.

@samdark
Copy link
Member

samdark commented Mar 31, 2014

@Ragazzo
Copy link
Contributor

Ragazzo commented Mar 31, 2014

@samdark yes , i know about that old bug in php , but i was talking about correct config that is not working even with that fix . Will try later to figure out what is wrong )

@jason-son
Copy link

@samdark
it's the best practice to use

php -S localhost:8000 index.php

for develop by native build-in server inside php

and add in index.php

$extensions = array("php", "jpg", "jpeg","png", "gif", "css","js");

$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$ext = pathinfo($path, PATHINFO_EXTENSION);
if (in_array($ext, $extensions)) {
    // let the server handle the request as-is
    return false;
}

so you can enable suffix in urlManager

otherwise, you can copy a index-dev.php for develop.

@Sammaye
Copy link

Sammaye commented Apr 2, 2014

I wouldn't say it is best practice; the built in PHP server is meant for light testing only, it is not designed to replicate a production environment where either Lighttpd/Nginx or Apache would run.

It is one way of doing it but I wouldn't affirm it is best practice unless you can quote the PHP documentation on it?

@qiangxue qiangxue added this to the 2.0 RC milestone Apr 16, 2014
@samdark
Copy link
Member

samdark commented Apr 29, 2014

Decided not to include .htaccess since nowadays nginx usage is very high and .htaccess is useless for it and many other webservers.

@samdark samdark closed this as completed Apr 29, 2014
@cebe cebe removed this from the 2.0 RC milestone Apr 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants