Forum Moderators: phranque

Message Too Old, No Replies

Yet another mod_rewrite question

Stupid Question

         

discolando

5:32 am on Jul 1, 2005 (gmt 0)

10+ Year Member



Hello, all. I have two questions regarding mod_rewrite to add to the long list. :)

What rule would I use to transform...

[spectrum5media.com...]

... to ...

[spectrum5media.com...]

That's the easier one. The trickier one is, I would like to be able to transform ...

[spectrum5media.com...]

... to ...

[spectrum5media.com...]

Is this possible? The value after the first / will always map to the 'template' variable, but after that there will be an unknown number of name/value pairs that need to be rewritten as &get=something. There might not be any, or their might be 10.

ChadSEO

9:43 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Although I have never had to do this myself, I have seen posts from other users who have. What they had to do was something like this:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /index.php?template=$1&$2=$3&$4=$5&$6=$7 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /index.php?template=$1&$2=$3&$4=$5 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /index.php?template=$1&$2=$3 [L]
RewriteRule ^([^/]+)$ /index.php?template=$1 [L]

discolando

9:52 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



So I basically have to decide the maximum number of name/value pairs allowed and work from there?

ChadSEO

9:55 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Exactly. It's not the most elegant solution, but I do know that it works.

discolando

9:59 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Also, I tried your example and I got an Internal Server Error. Are there any typos, because I wouldn't know. :)

ChadSEO

7:05 pm on Jul 5, 2005 (gmt 0)

10+ Year Member



Hmmm, I couldn't find any typos in it, but that doesn't mean there aren't any. If this is your webserver, I would try setting RewriteLogLevel to 2 (or higher), and see if the log can tell you anything. Also check the normal error log for info. If this is not your webserver, you probably cannot set these, as they do not work in an .htaccess file, so I would just comment out all the lines, and put them in one at a time, see if a particular line is causing you grief.