rackycz
(Dingdog)
November 13, 2017, 4:31pm
1
Hi.
I am creating this thread, because I want to inform about one missing thing in Guide 2.0:
Here is described how to enable nice URLs (without index.php and parameter r):
http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html#using-pretty-urls
I think that there is shown everything, only content of file /yiibasic/web/.htaccess is missing. Would it be possible to add following example to the link above? Without it nice URLs do not work.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
… I am using Windows7 + XAMPP
Yes, there is linked following page under the Guide (yellow box with Note), but it may not be obvious how to use it to all:
http://www.yiiframework.com/doc-2.0/guide-start-installation.html#recommended-apache-configuration
softark
(Softark)
November 16, 2017, 12:02pm
2
.htaccess on the web root is not always necessary.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
… I am using Windows7 + XAMPP
You could put this configuration in your httpd.conf instead of .htaccess since you have full access to your web server.
Sometimes, though, you will have to configure the web server using .htaccess , especially when you want to use a shared hosting service.
Guide > Special Topics > Shared Hosting Environment > Add extras for webserver
(http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html#add-extras-for-webserver )
And, this is important, .htaccess has no meaning for nginx web server. The configuration of it will be totally different.
All in all, this is a subject regarding "How to configure your web server to run a Yii application", rather than "How to enable pretty url in Yii".
Can you please share the instructions to configure nginx web server? Or point me to some guide available on the 'net?
softark
(Softark)
November 19, 2017, 11:10pm
4
The Definitive Guide to Yii 2.0 should be the first place to be visited.
Guide > Getting Started > Installing Yii > Configuring Web Servers > Recommended Nginx Configuration