Jump to content

simple mod_rewrite help


n000bie

Recommended Posts

Well, I am total new to mod_rewrite and can't grasp the basic. I am trying to convert my url from

 

http://localhost/mysite/activity.php?c_id=1&a_id=28

to

http://localhost/mysite/activity/components/articles

 

this is my htaccess code

 

Options +FollowSymLinks
RewriteEngine On
RewriteRule ([a-zA-z])+/([a-zA-z])\.html$ activity.php?c_id=$1&a_id=$2

 

It is not working, can anyone tell me what I am doing wrong.

 

Thanks

 

Link to comment
Share on other sites

a.) What seriously makes you think your current rule is remotely close. Even without any understanding of mod_rewrite it should be fairly obvious that a RewriteRule that contains .html is probably not right when neither of the URIs you have listed include .html.

 

b.) A rewrite is impossible given those two URLs, there is no possible way to convert one of those to the other using mod_rewrite.

Link to comment
Share on other sites

Just to clarify what I meant by it's not possible. A RewriteRule does exactly what the name suggests it 'Rewrites' the URL. This allows you to use either fixed values or values found in the URL that you are rewriting. Since your pretty URL doesn't include the numbers 1 or 28 you can't possibly redirect to that URL (unless you always want the value 1 & 28, but that would seem pretty pointless).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.