Giter Club home page Giter Club logo

Comments (6)

samdark avatar samdark commented on May 28, 2024 1

It will be documented on how to achieve it using a webserver at least.

from yii2-app-basic.

inwoker avatar inwoker commented on May 28, 2024 1

Working solution for 301 redirect:
RewriteEngine On

RewriteCond %{THE_REQUEST} ^GET.index.php [NC]
RewriteRule (.
?)index.php/(.) /$1$2 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

The only downside to this solution is that it redirects http://example.com/index.php/non-existing-url to http://example.com/non-existing-url instead of just showing 404. So I guess, more correct solution would be to do it on framework level. Or we can return 404 on server level, instead of 301 redirect for these cases.

Working solution for 404:
RewriteEngine On

RewriteCond %{THE_REQUEST} ^GET.index.php [NC]
RewriteRule ^ - [L,R=404]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

from yii2-app-basic.

cebe avatar cebe commented on May 28, 2024

I guess, to redirect to pages without index.php or throw 404 exception. That's up to debate.

you could set up your .htaccess file to do this.

from yii2-app-basic.

inwoker avatar inwoker commented on May 28, 2024

you could set up your .htaccess file to do this.

I guess. I just wanted to know if yii developers are aware of this. And maybe you should do something about it or not.

For example, you can setup removing/adding slashes in htaccess, but recently you released url normalizer which does this. So maybe something would be done on yii core level to remove index.php.

If not, and you guys don't consider it a bug, I suppose I would just find a solution for htaccess and use it in all my projects. Though probably, I can then write it here and it can be added to setup manual, for both htaccess and nginx config.

from yii2-app-basic.

inwoker avatar inwoker commented on May 28, 2024

@samdark Do I understand correctly that this will be fixed?

from yii2-app-basic.

cebe avatar cebe commented on May 28, 2024

Made an adjustment to the htaccess file in the guide, with a rule that works on / as well as subdirectories. Thanks for reporting and the solution!

from yii2-app-basic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.