Url Manager For Seo Friendly Url - 404 Error Code

Hello Community!

I have been trying to setup Url Manager. I want to be able to change the default url structure. I installed the Advanced template and I am currently using it as is…

url.com/index.php?r=messages/index

My target is to be able to use it like this…

url.com/messages/index

So I went thru the documentation at github (url.md)

I added an .htaccess file to my web folder and set frontend/web as my web root (following the instructions in Installation).

I added the Url Manager to the component list in my common/config/main-local.php




return [

    // ...

    'components' => [

        'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

        ],

    ],

];



I believe that’s all I need for it to work but I am getting a 404 not found error.

Now, something curious. Sometimes, i would show the blank 404 browser’s default page. BUT later on, it actually showed the 404 page provided by the Yii framework.

Any help would be highly appreciated.

Thanks

Sounds like htaccess can be somewhere else. Check that it’s inside webroot.

Also make sure that mod_rewrite is on.

Yes. mod_rewrite is on.

I placed the .htaccess in

/frontend/web/.htaccess

i pointed my web root to this folder as well.

Am i doing something wrong here?

This

can happen on IE (maybe some other browsers too) if some conditions are met (AFAIR received content length < ??? bytes + 404 status). I wonder if it’s fixed in 2014 :)

Ok, can you check mod_rewrite is working? for example, add some simple rules like


    RewriteCond %{REQUEST_URI} ^/test1

    RewriteRule ^.*$ /test2 [NC,L]



and try to request /test1

ORey,

I tried your suggestion. I added the two lines right after RewriteEngine on…

Nada.

Then I deleted the whole content and left only those three lines…

Nada.

I always get blank browser page with Not Found The requested URL /test1 was not found on this server.

Is there another way to check if mod_rewrite in on?

I can’t believe something as simple as that can create all this problem. :(

If you’re on mod_php:


<?= in_array('mod_rewrite', apache_get_modules()); ?>

PS. I suppose you’re using apache, right?..

[size="4"]Loaded Modules

core mod_so http_core prefork mod_authn_file mod_authn_core mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_core mod_access_compat mod_auth_basic mod_socache_shmcb mod_reqtimeout mod_filter mod_mime mod_log_config mod_env mod_headers mod_setenvif mod_version mod_ssl mod_unixd mod_status mod_autoindex mod_dir mod_alias mod_rewrite mod_php5[/size]

Yes, seems like it’s loaded.

Ok, one last thing to check: make sure that AllowOverride is set for webroot in your apache host configuration (etc/apache2/sites-available/… or some other place)

Also see this post: http://www.yiiframework.com/forum/index.php/topic/51470-pretty-urls-and-htaccess :D

[size="6"]ALELUYA!!!!!!!!!!!![/size]

The AllowOverride was set to NONE!!!!!

Thank you so much for your help ORey!

Good!

Btw here’s an important thing seb had pointed at in that post:

So the code can work on localhost but give 404 on server because of different apache versions. Probably worth mentioning in FAQ or something.