Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKevin Phillips
15,693 Points.htaccess not rewriting URLs.
The setup:
0.) Running MAMP on Mac OS X (10.10.2)
1.) Followed these directions on enabling mod_write in windows.
http://milesj.me/blog/read/mod_rewrite-xampp-windows
I am assuming the procedure should work on a mac.
2.) .htaccess placed inside my working directory of applications/mamp/htdocs/shirts4mike
(resolved all issues with includes, etc. with different root dir. from htdocs)
3.) Here are the contents of .htaccess that I have tried to use in light of the other discussions around this topic:
RewriteBase /shirts4mike/
RewriteEngine On
RewriteRule ^shirts/$ shirts/shirts.php
The error message:
404 Page Not Found. Index file does not exist.
(shirts.php and shirt.php placed inside shirts4mike/shirts/ ... seems like the browser is looking for an index file and my rewrite isn't being triggered at all?)
Further food for thought:
I have been unsuccessful in rewriting links to the contact page.
Please Help! Thanks!
3 Answers
Greg Kaleka
39,021 PointsMan, I had so much trouble setting this up... I did not use MAMP, so I did a lot of manual configuration of the Apache server. I don't remember my exact path to success, but this looks like some of the stuff I did haha. Hope it helps!
http://www.garron.me/en/mac/how-to-enable-htaccess-apache-mac-os-x.html
Note: nano is an easier text editor to use for beginners than vim, so I would replace vim with nano any time he says to use vim.
Kevin Phillips
15,693 PointsThanks again, Greg - The link you sent worked once I read the background information in this link first:
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
The main thing I learned, and was necessary to understand the directions in these links, is how to use the native server software that comes with OS X! I had no idea that was apart of the mix! On the Mac one is not reliant on MAMP!
My URL rewrites were not being triggered in MAMP but they are in AMP using the system level root.
It's time to go hang out with Randy and Mike again.
Greg Kaleka
39,021 PointsHah sweet! Glad you got it figured out. That page looks super familiar, and I think it probably helped me along the way as well.
Good luck sir!
Kevin Phillips
15,693 PointsProblems with .htaccess in Mac OS X? Are you accessing localhost correctly in the browser?
I was launching the shirts4mike site out of PHPStorm (IDE from JetBrains) which hosts the site at localhost:63342 by default (?).
Typing the localhost address in the browser seems to be the way to go - or setting up the IDE to point to it...(still haven't figured out that configuration step for PHPStorm and Sublime Text).
(Some) Mac OS X options for localhost:
localhost:8888 is the /Applications/MAMP/htdocs folder for MAMP, the default MAMP install.
localhost:80 is the /Library/WebServer/Documents folder for AMP. (See * for setup)
localhost:80/~username is the /User/username/Sites folder for AMP. (See * for setup)
As an example, I can put my site folder for shirts4mike in any of these directories:
/Applications/MAMP/htdocs/shirts4mike/
/Library/WebServer/Documents/shirts4mike/
/User/username/Sites/shirts4mike/
Further observations:
No "RewriteBase" needed in the .htaccess file.
Default install of MAMP worked fine for URL rewrites. No edits of the apache httpd.conf file needed as previously reported by others. Not sure why, of course!
Kevin Phillips
15,693 PointsKevin Phillips
15,693 PointsThanks, Greg! I'll give this a shot!