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 trialJimmy Maurice
9,379 Points$VAR_url and MAMP
Hi everyone ! I've got a problem with rewrite rules and MAMP. I'm working on a dynamic website which is already in production (online). There's some little bugs I need to fix. Because of this, I made a local installation with MAMP to run some tests. My problem is that all the URL have been cleaned with the rewrite mod within the file .htaccess
RewriteCond %{SCRIPT_FILENAME} !.+\..+
RewriteRule ^(.+)$ /category.php?VAR_url=$1 [L,NC]
It works normally online but not in MAMP.
In order to be like this: [http://www.mysite.com/category.php?VAR_url=$1] <br>
It gives this: [http://www.mysite.com/category1]
The problem is that in my local installation, I can access the home page which is like this:
[localhost/my-project/index.php]
But if I click on a dynamic link (like "category1"), it returns an error 404. I tried to access my page with the (not cleaned) Url by typing directly:
[http://www.mysite.com/category.php?VAR_url=category1 ] and it works.
So two Options:
1°) Delete the code which is modifying the URL I tried to delete my Rewrite rule but nothing happend.. Therefore the link in the html and in the data base is like this:
<a href="category1">category1</a>
(it doesn't refer to a page.html but to precise data in a table wich is correct)
2°) Understand what's goin'on, but it is much more difficult than option 1.
Any Ideas ? :)
2 Answers
thomascawthorn
22,986 PointsHere you'll find two badges 'Cleaning URLs with Subfolders' and 'Cleaning URLs with Rewrite Rules'. I'm pretty sure there's something in there that should help you with your local setup problems!!
Hope this helps
Jimmy Maurice
9,379 PointsThanks for your answer ! I found the solution in this course.
There was a problem with
$_SERVEUR["DOCUMENT_ROOT"]