Pretty Urls Internal Server Error

I’m quite new to Yii and Yii2, so this may be super-simple and I’m just missing it, but I can’t seem to get pretty URLs enabled properly. I am able to load the home page of the site, but then all other URLs are returning an Internal Server Error. I’m working with the Advanced Template and have not made hardly any customizations.

I’m trying to work it out based on the info on the URL.md page.

Here’s what I placed in my .htaccess file:




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 here is what I placed in the common/config/main.php file:




	...

	'components' => [

 	       'urlManager' => [

			'class' => 'yii\web\UrlManager',

			// Disable index.php

			'showScriptName' => false,

			// Disable r= routes

			'enablePrettyUrl' => true

        	],

        ...

	],

	...



Do I also need to set rules? I understood it as only needing rules for custom URLs, but so far the standard yii2 page URLs are returning Internal Server Errors.

Can anyone please help me understand what I am missing?

This is my first post, so it seems I am not allowed to share my test site URLs with you. If you need them, perhaps I can email them to you? Or maybe this will work …

develop.essenceguide[dot]com - works fine

develop.essenceguide[dot]com/site/signup - Internal Server Error

Thanks so much for any insight you can offer!

By the code you posted everything looks good.

What about without urlManager in config, does it work with "ugly" urls? I think you should double check your httpd configuration, maybe something with mod_rewrite?

Thanks so much for your input and assistance.

Yes, the site works perfectly with ugly urls. I’ve removed the urlManager from the config, and you can see it function now if you like.

develop.essenceguide[dot]com/index.php?r=site/about

I’ll definitely check the httpd configuration and test modrewrite. That’s great advice.

Again, many thanks!

.htaccess must be in the same folder as index.php of requested site (DocumentRoot)

(It also can be in some other folder but you need to modify it slightly).

THANK YOU, THANK YOU, THANK YOU!!! Few … that one had me stumped for a while.

Moving the .htaccess file to the frontend/web/ directory worked perfectly :)