We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Need some re-write magic for migrated site | Forum

fbkca
fbkca Oct 11 '13
hi, 


I've migrated from another platform and I'd like to redirect the profile URL's to the new ones...


This was the old URL:

www.example.com/profile.php?ID=usersprofile&lang=ru


All I need/want to carry to the new URL is the value in ID= so like this:


www.example.com/usersprofile


I've tried various examples already but none actually work, since the example are not quite the same as what I'm looking for...


Any suggestion?

Helike
Helike Oct 11 '13
Your point is show list of users or the page of a specific user?
fbkca
fbkca Oct 11 '13
it would be the user's actual profile, not a list.
Helike
Helike Oct 11 '13

An easy way is create a new file 'profile.php' (make sure to backup the old one) and do the following:

- The 'id' value is been passed to you file by GET, so you gonna get it and store in a variable.

- With the ID you'll need to access your database and see which user this ID is related and get it's username so you'll be able to construct the url (example.com/username)

- In your .htaccess you will put something like this: RewriteRule ^(\d+)*$ ./users/$1  


Another good way is use the current Oxwall url for users: yoursite.com/users/username

I that case, I'll not need to add anything in htaccess.


I did it by head and don't tested so I may missed or been mistake in something


Good Luck :D


The Forum post is edited by Helike Oct 11 '13
Helike
Helike Oct 11 '13
If need help, just contact me on Facebook. It's on my profile.
fbkca
fbkca Oct 11 '13
The ID's from my old site = the usernames of their accounts on oxwall, so all I really need it s redirect, keeping the value in ID= and simply then pointing it to exmaple.com/username   (I don't use the /users/ in my site.


So not sure what the rewrite rule would be just for that. I think making a profile.php is a little overkill, since I don't need to query the DB at all, simply re-direct.


Helike
Helike Oct 11 '13
May I see your site?
fbkca
fbkca Oct 24 '13
I still need help with this... anyone have any suggestions?
fbkca
fbkca Oct 24 '13
OK, I've found something that should be working, but I get en error when I use this:


RewriteRule ^([^/]*)$ /profile.php?ID=$1 [L]


However, if I put this in my .htaccess file the whole site craps out...


Apache logs this:


Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary

The Forum post is edited by fbkca Oct 24 '13
fbkca
fbkca Oct 24 '13
I thought perhaps I need to add the URI condition:


RewriteCond %{REQUEST_URI} !^/profile\.php

RewriteRule ^([^/]*)$ /profile.php?ID=$1 [L]


But still... I get the server error...

fbkca
fbkca Oct 25 '13
:(
fbkca
fbkca Oct 25 '13
thought maybe it neeed a query condition:


RewriteCond %{QUERY_STRING} ^ID=(.*)$ [NC]

RewriteRule ^profile\.php$ /%1


Still nothing working...


Anyone?

The Forum post is edited by fbkca Oct 25 '13
fbkca
fbkca Oct 25 '13
finally came up with this which seems to work.


RewriteCond %{REQUEST_URI}  ^/profile\.php$

RewriteCond %{QUERY_STRING} ^ID=(.*)&lang=(.*)$ [NC]

RewriteRule ^(.*)$ http://www.example.org/%1? [R=301,L]

RewriteCond %{REQUEST_URI}  ^/profile\.php$

RewriteCond %{QUERY_STRING} ^ID=(.*)$ [NC]

RewriteRule ^(.*)$ http://www.example.org/%1? [R=301,L]

The Forum post is edited by fbkca Oct 25 '13