Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.