0

After adding this htaccess in web folder:

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

and adding in components config/web.php

'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'enableStrictParsing' => false,
    'rules' => [
        // ...
    ],
],

then opening in the browser:

http://localhost/myiiproj/site/login

I have this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Did I miss something in configuration? Or is there other configuration to make this work?

arogachev
  • 33,150
  • 7
  • 114
  • 117
ashTon
  • 1,101
  • 4
  • 14
  • 23

2 Answers2

1

if you use apache server you must enable rewrite_module in httpd.conf, You can find httpd.conf in C:\wamp\bin\apache\apache2.4.9\conf directory. this is my directory, this directory may change therefore you must use your directory.Then you go line:

#LoadModule rewrite_module modules/mod_rewrite.so

and remove (#).You must change such as the following code.

LoadModule rewrite_module modules/mod_rewrite.so

save and close httpd.conf file.Restart your apache server.

Mahmut Aydın
  • 831
  • 13
  • 21
0
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L] 
</IfModule>

here is a simple htaccess to convert pretty url and make sure to enable mod_rewrite

or

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?mysite/(.*)$ /mysite/index.php/$1 [L]

from this post Yii how to get clean and pretty URL

Community
  • 1
  • 1
Oli Soproni B.
  • 2,774
  • 3
  • 22
  • 47