Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule Problem

Can't get multiple RewriteRule to work together

         

seodave

3:55 am on Aug 21, 2006 (gmt 0)

10+ Year Member



Is it possible to rewrite these URLs-

domain.com/?typ=#*$!
domain.com/#*$!.html

domain.com/?typ=#*$!&cat=YYY
domain.com/#*$!-YYY.html

domain.com/?typ=#*$!&cat=YYY&sct=ZZZ
domain.com/#*$!-YYY-ZZZ.html

First URL is the dynamic format, latter is desired URL.

Can do it by adding extra bits to the URLs, like

domain.com/?typ=#*$!
domain.com/#*$!.html

domain.com/?typ=#*$!&cat=YYY
domain.com/00-#*$!-YYY.html

domain.com/?typ=#*$!&cat=YYY&sct=ZZZ
domain.com/11-#*$!-YYY-ZZZ.html

But, not otherwise.

This is the .htaccess file contents so far-

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^index.html$ default.php
RewriteRule ^(.*)-(.*)-(.*).html?typ=$1&cat=$2&sct=$3 [QSA,L]
RewriteRule ^(.*)-(.*).html?typ=$1&cat=$2 [QSA,L]
RewriteRule ^(.*).html?typ=$1 [QSA,L]

Can only get the first rule to work (no matter what order I put them in).

BTW the space has been removed (by the forum software) between html and the question mark in the above code.

Thanks

David

jdMorgan

7:57 pm on Aug 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not entirely clear what the goal is here -- Whether you have changed the links on your pages to static format and wish to rewrite those to your script, or whether you've already done that, and are trying to clean up old dynamic URLs in search engine results. There *is* a trick to this, so I'll recommend that you review theChanging dynamic URLs to static URLs [webmasterworld.com] post in our forum library.

Jim

seodave

7:46 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



I have a script that creates dynmaic URLs in the format listed above (domain.com/?typ=KEYWORD), though the forum has messed my URLs above, it replaces x x x with #*$!

Got these dynamic URLs-
domain.com/?typ=KEYWORD
domain.com/?typ=KEYWORD&cat=KEYWORD2

Want these static URLs-
domain.com/KEYWORD.html
domain.com/KEYWORD-KEYWORD2.html

There are more similar versions.

Have edited the script so the URLs look like the above (in a browser), but I can't get more than one type of the static URL to work because of how the rules work together. So I can get KEYWORD.html or KEYWORD-KEYWORD2.html to work but not both at the same time.

Does that make sense?

I've rewrote the original question a bit to get past the forum software changing the URL.

Is it possible to rewrite these URLs-
domain.com/?typ=VVV
domain.com/VVV.html

domain.com/?typ=VVV&cat=YYY
domain.com/VVV-YYY.html

domain.com/?typ=VVV&cat=YYY&sct=ZZZ
domain.com/VVV-YYY-ZZZ.html

First URL is the dynamic format, latter is desired URL.

Can do it by adding extra bits to the URLs, like

domain.com/?typ=VVV
domain.com/VVV.html

domain.com/?typ=VVV&cat=YYY
domain.com/00-VVV-YYY.html

domain.com/?typ=VVV&cat=YYY&sct=ZZZ
domain.com/11-VVV-YYY-ZZZ.html

But, not otherwise.

So VVV is whatever the typ variable spits out, YYY the cat variable and ZZZ the sct variable.

David

jdMorgan

12:37 am on Aug 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Have edited the script so the URLs look like the above

So the script is now placing static-URL links on your pages, so that they may be clicked?

That is the first of the two most-often-required steps, with an optional third step, as outlined in the thread I cited above. If you haven't read that thread in-depth already, I commend it to you for a thorough, detailed read, as it addresses all aspects of this problem you're dealing with, and will likely give you a faster answer than having to walk through it step-by-step here.

As to your basic question, yes, it's possible to rewrite from static to dynamic, and to redirect from dynamic back to static, and that is most likely what you want to do if you want static URLs indexed in search engines for dynamically-created pages. And those steps are outlined in the cited thread.

Jim

seodave

6:58 pm on Aug 26, 2006 (gmt 0)

10+ Year Member



>So the script is now placing static-URL links on your pages, so that they may be clicked?

Yes.

>If you haven't read that thread in-depth already, I commend it to you for a thorough, detailed read,

I've read the page several times and don't see an answer to the problem?

I've not uses rules with this format before though-

RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?

Are you saying this is the problem that I can do what I want with that format?

>As to your basic question, yes, it's possible to rewrite from static to dynamic, and to redirect from dynamic back to static, and that is most likely what you want to do if you want static URLs indexed in search engines for dynamically-created pages. And those steps are outlined in the cited thread.

That's not what I asked.

This is a new script so don't have to deal with currently indexed dynamic pages (so no need for 301 redirects) and I'm not looking for static to dynamic rewrite rules. I just want dynamic to static URLs of a particular format using rewrite rules.

The difference between other scripts I've worked with is I'm trying for the format I listed previously which I think means the rewrite rules interfere with one another (I want to know if it's even possible to use that format).

Basically these three rules-

RewriteRule ^(.*)-(.*)-(.*).html?typ=$1&cat=$2&sct=$3 [QSA,L]
RewriteRule ^(.*)-(.*).html?typ=$1&cat=$2 [QSA,L]
RewriteRule ^(.*).html?typ=$1 [QSA,L]

So I get files with this structure-

1-2-3.html
1-2.html
1.html

The 3 rules work individually (so add just one to the .htaccess file and it works), but I can't get all three rules working at the same time.

Does that make sense?

If I change the rules and the script to create URLs like these-

uk-1-2-3.html
bob-1-2.html
1.html

Then it works, but I don't want to add the extra bits (uk and bob) if my preferred format is possible.

David