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 trial

PHP

I am not getting the "RewriteRules enabled.

I have created ".htaccess" and entered RewriteEngine On RewriteRule ^shirts/$ /shirts/shirts.php

and when I go to http://localhost/shirts.php I get object not found.

How do I enable Rewrite Rules?

If you can answer some questions, I'll try to help. What kind of OS do you have, are you using a local or remote server, if so, is your server local or remote and if the server you're using is local, did you install it manually or are you using a LAMP Environment program like MAMP or WAMP?

I am running Windows 7. I went to GitHub to download xampp

What exactly are you trying to rewrite? Like, what is the original URL and what are you trying to rewrite it too?

1 Answer

Inside your .htaccess file try typing this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^\w+$ shirts.php?page=$0 [L]
RewriteCond %{THE_REQUEST} shirts\.php
RewriteCond %{QUERY_STRING} ^page=(\w+)$
RewriteRule ^ shirts\.php$ /%1? [R=301,L]

Make sure the .htacces file is in the root folder of your template and only the root.

tried the above code and still got : Object not found Error 404

Disregard what I said and try copy and pasting this:

RewriteRule ^shirts/$ shirts/shirts.php

I just noticed you put a "/" in front of shirts in your original code. This may fix that.