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 Enhancing a Simple PHP Application Cleaning URLs with Rewrite Rules Get Variables and Rewrite Rules

Rafal Bachanek
Rafal Bachanek
28,766 Points

I have problem with my redirect with id

I wrote rules in .htacces

RewriteEngine ON
RewriteRule ^Lokale/$ /Lokale/restaurants.php
RewriteRule ^Lokale/([0-9]+)/$ /Lokale/restaurant.php?id=$1

first one works great, but second one returns back error:

Not Found

The requested URL /Lokale/101 was not found on this server.

1 Answer

Aaron Munoz
Aaron Munoz
11,177 Points

Have made sure that your server has rewrites enabled? And if it is, you might have caching issues. That's happened to me before and you can do something like break your code on purpose by setting the wrong url or something. Then undo it and boom, there it is. The rewrites begin to work.