How to use in .htaccess

Hi to all I am new for .htaccess

How can i use my code in .htaccess

echo "<td align='center'><a href='get_event_list_3.php?id=".$row['id']."'>" . $row['ename'] . "</a></td>\




how can I RewriteRule in .htaccess

The URL in your PHP script would need to be the URL rewrite version of the link, try the below


RewriteRule ^polite/([0-9]+)/?$ get_event_list_3.php?id=$1 [NC,L]


echo "<td align='center'><a href='polite/".$row['id']."'>" . $row['ename'] . "</a></td>\

Thank U SL Reply here

Its working but not satisfaction for my thoughts

http://localhost/polite/events/polite/1 (you suggesting)
http://localhost/polite/events/1 (I would like to get this)

I changed some code

 echo "<td align='center'><a href='".$row['id']."'>" . $row['ename'] . "</a></td>\


RewriteRule ^polite/([0-9]+)/?$ get_event_list_3.php?id=$1 [NC,L]

But I changed some code in but I am getting object not found and 404 error

Tried it this way:

RewriteRule ^([0-9]+)/?$ get_event_list_3.php?id=$1 [NC,L]

thank u mmarif4u working.

one more question how can I add ename to in id place

my code

echo "<td align='center'><a href='".$row['ename']."'>" . $row['ename'] . "</a></td>\


RewriteRule ^([a-zA-Z]+)$ get_event_list_3.php?id=$1 [NC,L]

localhost/polite/events/Dance (WORKING, Single word in ename)
localhost/polite/events/Songs Competition (Double words Not Working)

I am getting Object not found! Error 404

How can solve this problem

1st of all you should not use any space in URL. I would suggest to use - instaed of space.
For ename change the id in rule like, also consider digits 0-9 :

RewriteRule ^([0-9a-zA-Z]+)$ get_event_list_3.php?ename=$1 [NC,L]

I have added 0-9 to the rule to make it optional and workable.
Also i would suggest to use optional trailing slash in the rule in case some one entered this URL:
instead of this:

So the rule would like:

RewriteRule ^([0-9a-zA-Z]+)/?$ get_event_list_3.php?ename=$1 [NC,L]

Which will work for both type of urls.

Not working…

these two codes working for single words but not showing space words

RewriteRule ^([0-9a-zA-Z]+)$ get_event_list_3.php?ename=$1 [NC,L]

RewriteRule ^([0-9a-zA-Z]+)/?$ get_event_list_3.php?ename=$1 [NC,L]

give me any idea please

As i said above, you may be exclude space in your PHP script and use - or other char.
Any how You can change the rule to some thing like:

RewriteRule ^([^/\\.]+)/?$ get_event_list_3.php?ename=$1 [NC,L]

This will work for most of the char, and change the space to %20.
Try it, and let us know.


The short answer to your question is that you can’t make that redirection because the information is not in the URI that you’re using.

I suggest that you take a look at the mod_rewrite tutorial Article linked in my signature as it’s built from years of answering similar questions in this forum. Pay particular attention to an obscure little section where I recommend NOT using the id in the URI but using the ename. This HAS been implemented for years at