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.

Coding Forum


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



Reply
Old 12-23-2004, 11:25 PM Mod_Rewrite Dilema..
Brian07002's Avatar
Defies a Status

Posts: 2,140
Name: ...
Location: ...
Trades: 0
Hi,

I am using the webmaster-toolkit online generator to make a couple of rules for my website, but I am having a bit of a problem...

1.
Quote:
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /shop/index.php?$1=$2&$3=$4
if I input the above code into my .htaccess file, all works fine and dandy, the urls will become 'search engine friendly', but if I go and add a couple of additional rules with the above one included in the .htaccess file, none of the rules work...

Here are the other two rules:

2.
Quote:
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /shop/index.php?$1=$2&$3=$4&$5=$6
3.
Quote:
Options +FollowSymLinks
RewriteEngine on
RewriteRule index/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)/$ /shop/index.php?$1=$2&$3=$4&$5=$6&$7=$8&$9=$10
How do I add the additional rules into one file so it will work?

FYI: The rules have this effect:

Rule 1: Make all category pages search engine friendly
Rule 2: Make all sub-category pages search engine friendly
Rule 3: Make all product pages search engine friendly

Thank you for your support!
-Brian
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-24-2005, 05:21 AM
fambi's Avatar
Ultra Talker

Posts: 339
Trades: 0
Hi there.

If you havent solved your problem, i've also been through this.

Firstly, I found that mod rewrite happily accepted 9 variables, but no more.

To solve this, we have to understand how RewriteRules work:

Each (.*) represents one of those $ variables. So, if you know for sure what the variable names are going to be (e.g. $category, $subcategory etc.), you could take them out of the list of $1, $2 variables like this:

Rather than : RewriteRule index/(.*)/(.*)/(.*)/(.*)/$ /shop/index.php?$1=$2&$3=$4

Put this : RewriteRule index/category/(.*)/subcategory(.*)/$ /shop/index.php?category=$1&subcategory=$2

You can see that in action here : http://www.tm4b.com/useful_links/development_groups.php

My mod RewriteRule looks like this:RewriteRule useful_links/(.*).php$ /useful_links.php?class=$1

Although it originally looked like this: useful_links/(.*)-(.*).php$ /useful_links.php?$1=$2

This should half the number of $ in the RewriteRule.



Secondly, if RewriteRules share the same variables, they'll conflict with each other. So if you are calling the second of your described RewriteRules, it will think you are calling the first (for example).

The solution to that is to have only 1 RewriteRule and declare all the possible variable names in it, even if you leave the actual variables blank.

For example, if a user is looking a category page, the url should still declare the sub-category variable and the product variable, and just leave them blank.

So rather than : /shop/index.php?category=1

The url should read : /shop/index.php?category=1&subcategory=&product=

Hope it all makes sense.
__________________

Please login or register to view this content. Registration is FREE
from a
Please login or register to view this content. Registration is FREE
is easy!
Read this
Please login or register to view this content. Registration is FREE
that uses our
Please login or register to view this content. Registration is FREE
.

Last edited by fambi; 01-24-2005 at 05:59 AM.. Reason: Found an error in my code
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Reply     « Reply to Mod_Rewrite Dilema..
 

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.23677 seconds with 12 queries