Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
htaccess help! multiple variables and wildcards
Old 08-31-2008, 01:46 PM htaccess help! multiple variables and wildcards
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Hello,

Okay, im trying to write a working htacces mod_rewrite for the whmcs knowledgebase.

So i cannot modify the page code.. only htaccess so dont even suggest it.

anyway.

so far i have:
Code:
RewriteEngine On
Options +FollowSymlinks

RewriteRule ^knowledgebase$ knowledgebase.php
RewriteRule ^knowledgebase/$ knowledgebase.php
RewriteRule ^knowledgebase/([0-9]+)-(.*)$ knowledgebase.php?action=displaycat&catid=$1
RewriteRule ^knowledgebase/([0-9]+)-(.*)/([0-9]+)-(.*)$ knowledgebase.php?action=displayarticle&catid=$1&id=$2
and it all seems to work find up to:
Code:
RewriteRule ^knowledgebase/([0-9]+)-(.*)/([0-9]+)-(.*)$ knowledgebase.php?action=displayarticle&catid=$1&id=$2
now from what i have read it is the (.*) wild cards which are screwing up the variables.

the format i am aiming for is:
/knowledgebase/1-This-is-cat-one/5-this-is-article-five/

But have it so it works with /1-ANYTHING/5-ANYTHING/

if that makes sense, so i know of need wildcards which wont affect the variables.

Any ideas because this is doing my head in lol

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
 
Register now for full access!
Old 08-31-2008, 02:30 PM Re: htaccess help! multiple variables and wildcards
Novice Talker

Posts: 9
Trades: 0
You could try ^([a-zA-Z0-9_\-]+)-([0-9]+) (i preffer the id at the end)
And don't forget to add [L,NC] at the end of the rewrite rule.

Hope it works!
__________________

Please login or register to view this content. Registration is FREE
propress is offline
Reply With Quote
View Public Profile
 
Old 08-31-2008, 02:38 PM Re: htaccess help! multiple variables and wildcards
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
but wouldnt that still mess up the vars?

becuase i would end up with something like:
Code:
RewriteRule ^knowledgebase/^([a-zA-Z0-9_\-]+)-([0-9]+)/^([a-zA-Z0-9_\-]+)-([0-9]+)$ knowledgebase.php?action=displayarticle&catid=$1&id=$2
so wouldnt it mess it all up?

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 08-31-2008, 03:17 PM Re: htaccess help! multiple variables and wildcards
Novice Talker

Posts: 9
Trades: 0
I am a begginer with mod_rewrite but this is how i will do it:

RewriteRule ^knowledgebase/([a-zA-Z0-9_\-]+)-([0-9]+)/([a-zA-Z0-9_\-]+)-([0-9]+)\/$ knowledgebase.php?action=displayarticle&catid=$1&i d=$2 [L]

Here is an interesting guide, maybe it will help you : http://www.sitepoint.com/article/guide-url-rewriting
__________________

Please login or register to view this content. Registration is FREE

Last edited by propress; 08-31-2008 at 03:18 PM..
propress is offline
Reply With Quote
View Public Profile
 
Old 08-31-2008, 04:10 PM Re: htaccess help! multiple variables and wildcards
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
tried it it dont work

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 08-31-2008, 04:40 PM Re: htaccess help! multiple variables and wildcards
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
okay i did it in the end,

How would i go about having it without the ID numbers?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-01-2008, 04:58 AM Re: htaccess help! multiple variables and wildcards
Novice Talker

Posts: 9
Trades: 0
If it's not a very big website you could "manually" generate all the redirects.
I did that for a client and if work’s great.
__________________

Please login or register to view this content. Registration is FREE
propress is offline
Reply With Quote
View Public Profile
 
Old 09-01-2008, 04:07 PM Re: htaccess help! multiple variables and wildcards
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
i know i was readying something about having a text file which has like

friendlyname 12 (name and the ID)

but as it is for a knowledge base which has 137 articles, and they might chop n change categories etc i dont think it would work...

maybe having it dynamically generated some how? :s

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to htaccess help! multiple variables and wildcards
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21137 seconds with 12 queries