Jump to content

Trying to make clean URLs with mod_rewrite for Social Media page with user profiles, charts & more


great2gether

Recommended Posts

Hello everybody,

 

I am honestly quite a newb when it comes to mod_rewrite.

 

We run a small social media page with different areas and I would like to change the URLs to something more clean and professional.

 

User profiles look like this:

http://www.sky-mp3.com/index.php?action=cm&siteid=59&wahl=artists&tat=details&keyid=477

siteid 59 is the artists list and the keyid at the end is the ID of the artist

but should be like:

http://www.sky-mp3.com/mischura 

or in worse case like:

http://www.sky-mp3.com/user/mischura 

CMS pages look like this:

http://www.sky-mp3.com/index.php?siteid=106

but should be like:

http://www.sky-mp3.com/charts

(page name instead of siteid)

 

What I know so far:

- I have to add something to the .htaccess file

- I need to change something in the code (but I don`t know where)

 

Im good he? :geek:

 

What would be the first step on the path to clean URLs for me?

I found alot of infos here and there but found nothing yet for this specific case.

 

Kind regards from and thx in advance from Cologne

 

 

 

 

 

 

Link to comment
Share on other sites

You won't be able to do all of that with mod_rewrite. mod_rewrite (apache) knows nothing about your php code, how it works, or what the ids, for example, translate to. All it knows is what the requested URL is and can only rewrite it using the same values basically.

 

Like it has no way of knowing that siteid=59 translates to mischura as that's internal to your php app.

 

It could rewrite something like http://www.sky-mp3.com/index.php?action=cm&siteid=59

to

http://www.sky-mp3.com/cm/59

 

If your app used the username instead of the user ID, then it would work like you wanted, but you'd have to alter the way your app works and not use IDs and use the names of the entities instead. The app can get the user id based on the username.

http://www.sky-mp3.com/index.php?action=cm&siteid=mischura

could then be

http://www.sky-mp3.com/cm/mischura

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.