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

 

 

 

 

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.