Just got screwed, any who can help me?

Discuss practical ways rearrange URLs using mod_rewrite.

Just got screwed, any who can help me?

Postby aredondo » Fri Aug 07, 2009 12:20 pm

Hi.
A month ago i've was trying to get help online for an mod_rewrite problem.
Some dude (I cant say his name, i'm still trying to get my money back) said he could write the script for the amount of $300. He showed me some quick examples of what i could do, and i gave him the instructions and 300 bucks..

After some time I got the .htaccess file and it did not do what I wanted... not at all... So, here i am, still no solution to my problem..

So, is there a kind soul here who could help me out?
I'm trying to turn this:
Code: Select all
index.php?user=john&page=about,contact,email&action=post&ticket=1234

Into this:
Code: Select all
site.com/john/about/contact/email/post/1234


This the unamed dude almost manage to do for me.. He could't split the pages (page=about,contact,email) but here is the twist..
Sometimes the "user" parameter dont exist, just:
Code: Select all
index.php?page=about,contact,email&action=post&ticket=1234


And.. Sometimes i need additional query strings after, like this
Code: Select all
site.com/john/about/contact/email/post/1234/foo=bar&num=two&more=stuff
aredondo
 
Posts: 3
Joined: Fri Aug 07, 2009 12:06 pm

Postby richardk » Fri Aug 07, 2009 1:55 pm

Unless there is always three "pages", the problem is given /a/b/c/d/post/1234/ it could be either /index.php?user=a&page=b,c,d&action=post&ticket=1234 or /index.php?page=a,b,c,d&action=post&ticket=1234.

Does the value of page change?
Can you provide some more examples?
What is the maximum number of "pages"?
Is there a set list of "pages"? (Then anything else would be a username.)

What are the values of action? (Or can there be any value?)
Will ticket always be present and numeric?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby aredondo » Sun Aug 09, 2009 7:47 am

there could be one page, three pages or ten pages.. but my script only reads the last page.. So yes, the value of pages change..
I'm thinking of changing it to only one page, might be the smartest choise..

Action could be anything
ticket is not always numeric

So, the string could look like this:
Code: Select all
index.php?user=john&page=foo&action=post&ticket=1234
site.com/john/foo/post/1234

or
Code: Select all
index.php?page=foo&action=post&ticket=1234
site.com/foo/post/1234

or
Code: Select all
index.php?page=foo&action=post
site.com/foo/post

or
Code: Select all
index.php?page=foo
site.com/foo


EDIT:
I've just talk'ed to this guy on IRC, he told me this was near impossible to do this way.. He suggested using "subdomain" for the users..
i.e
www.site.com -> no "user"
john.site.com/foo/post/1234 -> with "user"

Is this a better solution?
aredondo
 
Posts: 3
Joined: Fri Aug 07, 2009 12:06 pm

Postby richardk » Wed Aug 12, 2009 10:53 am

He suggested using "subdomain" for the users..
i.e
www.site.com -> no "user"
john.site.com/foo/post/1234 -> with "user"

Is this a better solution?

It should work. You would need DNS for the sub domains (probably Wildcard DNS) and the server would need to send all the sub domain requests to your document root (not a sub directory for each sub domain).

Or you could do something like
Code: Select all
/user/john/foo/post/1234
or
/user:john/foo/post/1234
or
/u-john/foo/post/1234
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby aredondo » Thu Aug 13, 2009 12:57 am

If you where to help me write this, how much money do you want?
index.php?user=john&page=foo&action=post&ticket=1234&foo=bar&bar=code

site.com/john/p/foo/post/1234/?foo=bar&bar=code
or
site.com/p/foo/post/1234/?foo=bar&bar=code

"p" is page
aredondo
 
Posts: 3
Joined: Fri Aug 07, 2009 12:06 pm

Postby richardk » Fri Aug 14, 2009 1:11 pm

ticket is not always numeric

Then you're going to need something (like t/) to identify it as well. And action as well.

Or you could use /john/about,contact,email/post/1234/foo=bar&num=two&more=stuff instead.

If you where to help me write this, how much money do you want?

None.

site.com/john/p/foo/post/1234/?foo=bar&bar=code
or
site.com/p/foo/post/1234/?foo=bar&bar=code

"p" is page

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(?:([^/]+)/)?p/(.+)/a/([^/]+)t/([0-9]+)/?$ /index.php?user=$1&page=$2&action=$3&ticket=$4 [QSA,L]
RewriteRule ^(?:([^/]+)/)?p/(.+)/a/([^/]+)/?$ /index.php?user=$1&page=$2&action=$3 [QSA,L]
RewriteRule ^(?:([^/]+)/)?p/(.*[^/])/?$ /index.php?user=$1&page=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 25 guests

cron