Rewriting urls with mod_rewrite - GET variables

I found out I could make clean urls with mod_rewrite. I managed to make pages like /home.php viewable by visiting /home (without .php).

Now, I'd like to turn view_album.php?album_id=23 into album/23

This is the code I use, but sadly it's not working:

Options SymLinksIfOwnerMatch MultiViews
RewriteEngine On
RewriteBase /beta/
RewriteRule ^album/(.*)/ view_album.php?album_id=$1

Thanks in advance.

Answers


use

RewriteEngine On
RewriteBase /beta/
RewriteRule ^album/([0-9]*)$ view_album.php?album_id=$1

and make sure you only rewrite if a noting or a number follows album/, so your can access your images, which may be in a folder named album.


Need Your Help

test a function that returns triangle type

c++ c testing integration-testing

I got the following question as part of a screening interview:

How to add a number to its own index

c#

I will have a number which was taken as input from the use or i am storing a number assigned to a string as

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.