bc24fl Posted May 22, 2013 Share Posted May 22, 2013 So I'm following along and can't seem to get this htaccess right. A little help would be much appreciated. When I remove index.php i get the 404 error. Environment: Windows 7 / Zend Server Apache http://localhost:8080/testapp/index.php .htaccess inside the /testapp/ dir is: ------ <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> ------ main.php contains: 'showScriptName'=>false in httpd.conf AllowOverrides All Link to comment Share on other sites More sharing options...
matthuisman Posted May 27, 2013 Share Posted May 27, 2013 I had a few issues with the .htaccess as well. I ended up using the below which works for me. Options +FollowSymLinksIndexIgnore */*<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 [L]</ifModule> Link to comment Share on other sites More sharing options...
Larry Posted June 1, 2013 Share Posted June 1, 2013 Thanks for sharing that. bc24fl, did that work for you? Link to comment Share on other sites More sharing options...
Gio Posted February 6, 2014 Share Posted February 6, 2014 I know that this is an old thread but wanted to share that I had the same problem with the OP. matthuisman's suggestion didn't work on my setup on Ubuntu13.10 with apache2.4.6. Instead, I had to add the following to my /etc/apache2/sites-available/mysite.conf <Directory /var/www/mysite/> Options Indexes FollowSymLinks AllowOverride All </Directory> Then reload apache with sudo service apache2 restart Hope this helps someone. 1 Link to comment Share on other sites More sharing options...
Larry Posted February 7, 2014 Share Posted February 7, 2014 Thanks for taking the time to share what worked for you! Link to comment Share on other sites More sharing options...
gmeader Posted February 22, 2014 Share Posted February 22, 2014 To enable Apache mod_rewite you can give the following command in Ubuntu Linux: sudo a2enmod rewrite It will respond with: Enabling module rewrite. To activate the new configuration, you need to run: service apache2 restart 1 Link to comment Share on other sites More sharing options...
sandy Posted April 21, 2014 Share Posted April 21, 2014 This was a huge help. Here are a few more things to check, I'm running Ubuntu/Mint 15 on a virtualBox instance. I could not get the simple examples working, .htaccess and the code was as the book has but no-go. Looked at the apache2 enabled modules in /etc/apache2/mods-enabled and saw that their was a symlink set up to rewrite.load so the module was setup for loading. Then took a look at /etc/apache2/sites-enabled directory, it has one entry in my case which is a symlink to the /etc/apache2/sites-available/default file where I found pretty much what Gio said, <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride none Order allow,deny allow from all </Directory> I just changed the AllowOverride none to AllowOverride all and restarted apache2 as Gio did below. Lastly Don't forget to add the 'showScriptName'=>false, Line to the 'urlManager' section in config/main.php file as the book shows, it's easy to miss. And Thank You GIO! Sandy I know that this is an old thread but wanted to share that I had the same problem with the OP. matthuisman's suggestion didn't work on my setup on Ubuntu13.10 with apache2.4.6. Instead, I had to add the following to my /etc/apache2/sites-available/mysite.conf <Directory /var/www/mysite/> Options Indexes FollowSymLinks AllowOverride All </Directory> Then reload apache with sudo service apache2 restart Hope this helps someone. Link to comment Share on other sites More sharing options...
Larry Posted April 24, 2014 Share Posted April 24, 2014 Awesome. Thanks for sharing everyone! Link to comment Share on other sites More sharing options...
sandy Posted April 25, 2014 Share Posted April 25, 2014 One more .htaccess post - Moving your Yii app out of web root Just got the rest of my .htaccess working for the Yii app I have been working on. The Yii app is in a subdir under the web root. This seems to work well and is similar to some of the above examples, posting as it's always madding dealing with .htaccess and making things work ... This was cobbled from some other .htaccess files I had found. Put this in your webroot's .htaccess not in the local Yii App directory replace subdir with the directory that your yii app is in (with index.php) replace yourdomain with the domain name of the site (may be other ways to do this without explicitly setting this) As always use .htaccess on a test instance before crashing your web server... ============ .htaccess at web root ============ # allow no one to read .htaccess <Files .htaccess>order allow,denydeny from all</Files> # Common options, hide directory listing, etcOptions ALL -Indexes +SymLinksIfOwnerMatch# Allow first html then php index files to be the defaultDirectoryIndex index.html index.php # Must have this!RewriteEngine on # May be the default, but doesn't hurtRewriteBase /# Don't apply rules to URLs that are existing files or folders.RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# Only apply to URLs that aren't already under /subdirRewriteCond %{REQUEST_URI} !^/subdir/# Rewrite all those to insert /subdir.RewriteRule ^(.*)$ /subdir/$1# Redirect the root folder.RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$RewriteRule ^(/)?$ subdir/ [L] Link to comment Share on other sites More sharing options...
Recommended Posts