bc24fl 0 Posted May 22, 2013 Report 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 Quote Link to post Share on other sites
matthuisman 0 Posted May 27, 2013 Report 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> Quote Link to post Share on other sites
Larry 428 Posted June 1, 2013 Report Share Posted June 1, 2013 Thanks for sharing that. bc24fl, did that work for you? Quote Link to post Share on other sites
Gio 1 Posted February 6, 2014 Report 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 Quote Link to post Share on other sites
Larry 428 Posted February 7, 2014 Report Share Posted February 7, 2014 Thanks for taking the time to share what worked for you! Quote Link to post Share on other sites
gmeader 1 Posted February 22, 2014 Report 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 Quote Link to post Share on other sites
sandy 2 Posted April 21, 2014 Report 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. Quote Link to post Share on other sites
Larry 428 Posted April 24, 2014 Report Share Posted April 24, 2014 Awesome. Thanks for sharing everyone! Quote Link to post Share on other sites
sandy 2 Posted April 25, 2014 Report 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] Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.