Still Having Url Problems

So far these are the steps i’ve taken.

added .htaccess to web folder




RewriteEngine on


# If a directory or a file exists, use the request directly

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward the request to index.php

RewriteRule . index.php



Added this to my config




'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'rules' => [

                'about' => 'site/about',

            ],

        ],



cgi.fix_pathinfo=0 in php.ini

Currently my debug toolbar “Was not found on this server” and my default “about” is also “not found on this server”. Checked Apache2 logs too, couldn’t see any problems with the rewrite module too.

What else can it be? I’m on a mac, not having this issue on Windows 7 though.

You should check your Apache configuration files. In almost all the ones I have recently looked at the ModRewrite module is either not installed or not enabled. If they are then look in the apache conf file to make sure you see the line that looks for something like this -

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews


AllowOverride [b]none[/b]


Order allow,deny


allow from all

</Directory>

Change it to something like this

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews


AllowOverride [b]ALL[/b]


Order allow,deny


allow from all

</Directory>

This allows the .htaccess options to do things, otherwise they are ignored.

In the webroot I have .htaccess like this -


<Files .htaccess>

order allow,deny

deny from all

</Files>


Options ALL -Indexes +SymLinksIfOwnerMatch


# Allow first html then php index files to be the default

DirectoryIndex index.html index.php


RewriteEngine on

RewriteBase /


# Don't apply to URLs that go to existing files or folders.

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d


# Only apply to URLs that aren't already under my directory

RewriteCond %{REQUEST_URI} !^/YOUR_YII_DIRECORY_NAME_HERE/


# Rewrite all those to insert to app.

RewriteRule ^(.*)$ /YOUR_YII_DIRECORY_NAME_HERE/$1


# Redirect the root folder.

RewriteRule ^(/)?$ YOUR_YII_DIRECORY_NAME_HERE/ [L]




In the application directory I have .htaccess like this


<ifModule mod_rewrite.c>

# Turn on the engine:

RewriteEngine on

# Don't perform redirects for files and directories that exist:

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

# For everything else, redirect to index.php:

RewriteRule ^(.*)$ index.php/$1

</ifModule>



The first htaccess in my webroot allows me to redirect to the app if landing on the webroot by url, so will allow www.xyz.com to redirect to the YOUR_YII_DIRECORY_NAME_HERE directory where the app is. The second allows me to fix up the pretty url.

I would first verify that your Apache conf’s are OK and that .htaccess is being used for the rules…

Your mileage may vary with the way I did the htaccess files, test on a private server so you don’t have any issues on a production or shared box.

HTH

Sandy

Thanks Sandy

Adjusting my apache conf file to "All" was all it needed!

No problem, I spend a long while trying to figure it out only to realize later that the .htaccess was not doing anything. It’s a steep learning curve to toss in apache, php, yii, sysadmin all at once and I should start keeping track of all the things like this. It’s funny I set up a new instance and ran into the same problem and finally the dim bulb went on that said check the conf files for override ALL, sure enough same problem. I’m slow to learn :)

Glad to give back to the community on an easy question :)

Sandy