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

RewriteRule not working properly on godaddy

Hey guys, i'm trying to get the RewriteRule in .htaccess to work on a godaddy hosting account. This is for the Shirts4Mike page (I can't install xamp on this computer, it's not mine).

Here is my directory configuration:

public_html/phplearn/shirts4mike/shirts/

I want to use a rewrite that whenever that subdirectory is requested, it displays

public_html/phplearn/shirts4mike/shirts/shirts.php

The .htaccess file is within the shirts4mike folder, with the following code:

RewriteEngine On
RewriteRule ^phplearn/shirts4mike/shirts/$ /shirts/shirts.php

When I try to load the page www.domain.tld/phplearn/shirts4mike/shirts/ this gives me a 403 forbidden error (directory listing page prohibited) with "Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

What am I doing wrong?

EDIT: FOUND the solution. The pattern in the RewriteRule should be a relative URL from where the .htaccess file is located:

For those that may search in the future - My configuration should have been:

RewriteEngine on
RewriteRule ^shirts/$ shirts/shirts.php