Application templates: missing .htaccess #2800

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

Comments

Projects
None yet
10 participants
@alpharder

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

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Mar 18, 2014

Member

Probably a good idea.

Member

samdark commented Mar 18, 2014

Probably a good idea.

@samdark samdark self-assigned this Mar 18, 2014

@alpharder

This comment has been minimized.

Show comment
Hide comment
@alpharder

alpharder Mar 18, 2014

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

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

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Mar 18, 2014

Member

What do you mean by useful configurations?

Member

samdark commented Mar 18, 2014

What do you mean by useful configurations?

@alpharder

This comment has been minimized.

Show comment
Hide comment
@alpharder

alpharder Mar 18, 2014

We could probably use html5-boilerplate .htaccess file

We could probably use html5-boilerplate .htaccess file

@SonicGD

This comment has been minimized.

Show comment
Hide comment
@SonicGD

SonicGD Mar 19, 2014

Contributor

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

Contributor

SonicGD commented Mar 19, 2014

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

@e6nian

This comment has been minimized.

Show comment
Hide comment
@e6nian

e6nian Mar 19, 2014

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

e6nian commented Mar 19, 2014

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

@samdark

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Mar 19, 2014

Member

@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.

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.

@samdark samdark added the type:docs label Mar 19, 2014

@Sammaye

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye 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.

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

This comment has been minimized.

Show comment
Hide comment
@klimov-paul

klimov-paul Mar 19, 2014

Member

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

Member

klimov-paul commented Mar 19, 2014

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

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Mar 19, 2014

Contributor

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.

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

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Mar 19, 2014

Member

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

Member

samdark commented Mar 19, 2014

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

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Mar 19, 2014

Contributor

it works when you set showScriptName to false ? strange )

Contributor

Ragazzo commented Mar 19, 2014

it works when you set showScriptName to false ? strange )

@o-rey

This comment has been minimized.

Show comment
Hide comment
@o-rey

o-rey Mar 31, 2014

Contributor

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

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.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Mar 31, 2014

Contributor

@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 )

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 )

@e6nian

This comment has been minimized.

Show comment
Hide comment
@e6nian

e6nian Apr 2, 2014

@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.

e6nian commented Apr 2, 2014

@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

This comment has been minimized.

Show comment
Hide comment
@Sammaye

Sammaye 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?

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

This comment has been minimized.

Show comment
Hide comment
@samdark

samdark Apr 29, 2014

Member

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

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 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