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 trialJorge Alcala
4,500 PointsRedirecting code do not take me to the new link, instad It will take me to the root Ejp: http://localhost/C:/xampp/htdoc
This is my code:
RewriteEngine On RewriteRule ^shirts/$ shirts/shirts.php RewriteRule ^shirts/([0-9]+)/$ shirts/shirt.php?id=$1 RewriteRule ^receipt.php$ receipt/ [R=301] RewriteRule ^contact.php$ contact/ [R=301] RewriteRule ^shirts.php/$ shirts/ [R=301]
the Redirection part do not work, it take me to: http://localhost/C:/xampp/htdocs/shirts4mike_2/shirts/
Dose someone know what is my problem?
4 Answers
Montalvo Miguelo
24,789 PointsYou should set the base of your application in your .htaccess file to get the correct url
RewriteBase /shirts4mike_2/
julcap
16,274 PointsI think I was having a similar problem since my site was not in the root (rather it was is localhost/shirts4mike/)
I was able to fix the problem using RewriteBase /shirts4mike/
no idea if this will cause I problem when you publish (wouldnt surprise me if it did)...
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritebase
would be interesting in hearing from an expert if this is the best/right fix...
Iain Simmons
Treehouse Moderator 32,305 PointsWhat URL are you putting in to the location/address bar in Chrome/IE?
Also, note that the last RewriteRule has a trailing slash after the shirts.php
. Normally people wouldn't include a slash after a file extension, only after a directory...
Leo Maltrait
19,697 PointsHi,
I got pretty much the same problem than yours, Jorge Alcala (except it was with MAMP on mac).
The best solution I could find (since "RewriteBase /shirts4mike/" didn't work for me) was to put: RewriteRule ^receipt.php$ http://localhost:8888/shirts4mike/receipt/ [R=301]
instead of: RewriteRule ^receipt.php$ receipt/ [R=301]
And I guess I'll change localhost to my domain name when I won't work locally anymore.
Cheers
Jorge Alcala
4,500 PointsJorge Alcala
4,500 Pointsok well I think is chrome that cause this problem, using IE it take me to the right link: http://localhost/shirts4mike_2/shirts/