-1

I am working on a multiple language site. For a URL .com/business-industry/?parent_id=3&value=cars it works perfectly. This will make the URL .com/business-industry/3/cars But the site also has .com/nl/ and .com/de/ I've added the next rules to .htaccess. The first one works but the second and third for /nl and /de doesn't work.

The second one has to go for example from .com/nl/business-industrie/?parent_id=3&value=cars to .com/nl/business-industrie/3/cars

RewriteEngine On
RewriteRule ^business-industry/([0-9]*)/(.*)/?$ /index.php?business-industry=1&parent_id=$1&value=$2 [NC,L]

RewriteRule ^nl/business-industrie/([0-9]*)/(.*)/?$ /index.php?business-industrie=1&parent_id=$1&value=$2 [L]

RewriteRule ^de/business-branche/([0-9]*)/(.*)/?$ /index.php?business-branche=1&parent_id=$1&value=$2 [NC,L]

Much appreciation for the help.

Thanks in advance.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
  • Is "/index.php?business-industrie=1" always equal to "1" for all languages? A link to the working site without rewrites would be helpful... – Minister Jan 20 '14 at 12:45
  • This question appears to be off-topic because it is about SEO – John Conde Jan 20 '14 at 12:49
  • Where should these people be posting their questions? – Tony McCreath Jan 20 '14 at 13:41
  • Hey Mister, this is the variable from the database (PHP). It can be also 4 but then it's not cars but trains for example. For each language the ID is the same. @John Sorry but i only filled in the questions and tags. – user3214990 Jan 20 '14 at 13:47
  • @JohnConde No, it's a programming question about an Apache Module called mod_rewrite. It exceeds the regular 'server configuration' (setting some flags here, setting some constants there) and the question is *not* an abstract question about SEO (what url is better?). I find it perfectly on-topic for StackOverflow, although the amount of people that can provide an useful answer to these kind of questions is more limited than, for example, php. – Sumurai8 Jan 25 '14 at 14:03
  • 1
    @Sumurai8 Mod_rewrite questions belong on pro webmasters as do seo questions. This question is off-topic here no matter how you look at it. – John Conde Jan 25 '14 at 14:40
  • @JohnConde No, it is *also* on-topic on pro webmasters, but the existance of pro webmasters doesn't make all Apache, IIS, Javascript, Html and CSS questions off-topic on StackOverflow. – Sumurai8 Jan 25 '14 at 21:29
  • @Sumurai8 This is an SEO and mod_rewite question. It only belongs at Pro Webmasters. This was decided a *long* time ago. If you disagree post on Meta and see what they have to say about it. – John Conde Jan 25 '14 at 22:09
  • 4
    This has less to do with programming and more with routing URLs, Webmasters SE – random Jan 25 '14 at 22:23
  • @JohnConde You don't seem to have taken part in any discussion on mod_rewrite or seo on meta (apart from how the seo of stackexchange is) and 'mod_rewrite' and 'seo' don't exist in the same question on meta. Furthermore you have barely any answers on mod_rewrite here or on webmasters (14 combined?). So show me the topic. – Sumurai8 Jan 25 '14 at 22:39
  • @Sumurai8 I didn't make the decision and I don't see how my participation in mod_rewrite questions is relevant. By that logic my participation in the SEO tag here and at Pro Webmasters would mean what I say about this topic is gold. (It isn't and I don't pretend it is). – John Conde Jan 25 '14 at 22:45
  • Unless you've got something constructive to offer I will no longer participate in this conversation. – John Conde Jan 25 '14 at 22:54
  • It's a WP related rewrites question, that is used for both SEO and human friendly URLs, so it seems to fit good here. It definitely isn't SEO-only related question! The OP should include all additional information requested from the comments (WP single/multisite, multilang plugins used...) in the question (edit it, please!) to have better chances for a working answer... and to try a few more proposed solutions... :-) – Minister Jan 26 '14 at 22:18

1 Answers1

1

Replace your 3 rules with this single rule:

RewriteEngine On

RewriteRule (?:^|/)(business-[^/]+)/([0-9]+)/([^/]*)/?$ /index.php?$1=1&parent_id=$2&value=$3 [NC,L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Hi thanks for your reply! This rule only works with the int site and not with /de. Even if i changed the second rule to RewriteRule (?:^|/)business-branche/([0-9]+)/([^/]*)/?$ /index.php?business-branche=1&parent_id=$1&value=$2 [NC,L,QSA] – user3214990 Jan 20 '14 at 13:54
  • Try updated code now. – anubhava Jan 20 '14 at 13:56
  • 1
    In case the updated code doesn't work, I think that one could do the task (one more param): RewriteRule (?:^|/)(business-[^/]+)/([0-9]+)/([^/]*)/?$ /index.php?$1=1&parent_id=$2&value=$3 [NC,L,QSA] – Minister Jan 20 '14 at 14:09
  • @Minister: Thanks so much, I edited my code to reflect that suggestion. – anubhava Jan 20 '14 at 14:15
  • @anubhava You are always welcome! – Minister Jan 20 '14 at 14:16
  • Thanks for the suggestion but it still doesn't work. – user3214990 Jan 20 '14 at 14:33
  • Thanks for the suggestion but it still doesn't work. I have the feeling that the Wordpress function.php is overruling the /nl and /de. If i change the slug URL to ?parent_id=3&value=cars it works perfect on every button. I want to give the URL but it's secure. What the template does is it looks at the language. Is it en it goes to .com/business-industry/?parent_id=$&value=$. From the database i only get parent_id 1, 2, 3 till 10 which has a value 1=cars 2=trains 3=bus. In the rewrite for the 'root' so .com/ it works perfect but the problem is in the /de and /nl – user3214990 Jan 20 '14 at 14:39
  • Is it WP Multisite? It seems the URL is needed for WP to choose which site is accessed, so rewriting all to /index.php... isn't enough and the LANG prefix (if exists) should be kept (one more param, but an optional one). Probably something like this could work (anubhava should check if it's a valid one): RewriteRule ^((de|nl)/?)?(business-[^/]+)/([0-9]+)/([^/]*)/?$ $1/index.php?$2=1&parent_id=$3&value=$4 [NC,L,QSA] – Minister Jan 20 '14 at 14:50
  • 1
    Actually OP never told before about presence of WP before. Just for testing purpose first try adding `R` flag in above answer to see whether desired URL is the outcome of this rule and it is loading the correct content. Try this rule: `RewriteRule (?:^|/)(business-[^/]+)/([0-9]+)/([^/]*)/?$ /index.php?$1=1&parent_id=$2&value=$3 [NC,L,QSA,R]` – anubhava Jan 20 '14 at 14:53
  • It goes to .com/?business-process=1&parent_id=7&value=hrm if i use RewriteRule ^business-process/([0-9]*)/(.*)/?$ /index.php?business-process=1&parent_id=$1&value=$2 [NC,L,QSA,R] it has to go to .com/business-process/?parent_id=7&value=hrm. than it will work :) – user3214990 Jan 21 '14 at 15:11
  • Can you try this rule: `RewriteRule (?:^|/)(business-[^/]+)/([0-9]+)/([^/]*)/?$ /index.php?$1=1&parent_id=$2&value=$3 [NC,L,QSA,R]` – anubhava Jan 21 '14 at 15:21
  • If i add that rule it goes to .com/?business-process=1&parent_id=8&value=order-to-cash and i don't see the content – user3214990 Jan 21 '14 at 15:48
  • Is it 404 or just blank page? What URL is correct instead of `.com/?business-process=1&parent_id=8&value=order-to-cash`? Is `.com/index.php?business-process=1&parent_id=8&value=order-to-cash` working? – anubhava Jan 21 '14 at 15:52
  • Also goes to the same page, it's not a 404 but it doesn't get the content. .com/business-process/?proc_id=3&value=finance-and-controlling gets the right content... if i go to .com/business-process/3/finance-and-controlling it now goes to .com/?business-process=1&parent_id=3&value=finance-and-controlling Thanks for your patience :) – user3214990 Jan 21 '14 at 16:00