Comments (6)
It will be documented on how to achieve it using a webserver at least.
from yii2-app-basic.
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.
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.
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.
@samdark Do I understand correctly that this will be fixed?
from yii2-app-basic.
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)
- options with alias dose not resolved in function registerLinkTag HOT 1
- Can't update 2amigos/qrcode-library HOT 1
- yii2.0.46 using oci8-could not find driver HOT 4
- Wrong version while installation via composer HOT 4
- Requirement codeception/module-filesystem ^2.0 || ^1.1 conflicts with codeception/codeception 5.0 HOT 3
- ItΒ΄s possible update phpunit/phpunit to 10? HOT 1
- CSS issues with Bootstrap HOT 2
- Cannot Get Working Setup for Running Acceptance Tests according to README HOT 2
- I had the same problem - codeception/module-yii2[1.1.0, ..., 1.1.1] require php >=5.6.0 <8.0 -> your php version (8.2.0) does not satisfy that requirement.
- update github folder link
- update assets folder links
- update commands folder links
- update tests folder links
- update views folder links
- update root folder links
- composer.lock file is in .gitignore HOT 1
- UrlManager::buildRules() called with a boolean instead of array when unit testing HOT 3
- Why is phpunit/phpunit a root requirement?
- How to build projects on top of this repo? HOT 3
- yii\bootstrap5\Navbar collapseOptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-app-basic.