Welcome to WebmasterWorld Guest from 54.196.175.173

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod rewrite not working in openSUSE

Works in WAMP and on live server but not in openSUSE

     

Jay7

10:41 am on Nov 21, 2010 (gmt 0)

10+ Year Member



I have the following rule on one of my sites:

RewriteEngine On
RewriteRule ^([0-9a-zA-Z\-]*)(/?)([0-9a-zA-Z\-\+\_\']*)(/?)([0-9a-zA-Z\-\+\_\%\']*)(/?)([0-9a-zA-Z\-\+\_\%\']*)(/?)([0-9a-zA-Z\-]*)(/?)$ index.php?id1=$1&id2=$3&id3=$5&id4=$7&id5=$9


The aim is to redirect the following:

http://www.example.com/europe/uk/england/bristol/clifton/


to this:

http://www.example.com/index.php?id1=europe&id2=uk&id3=england&id4=bristol&id5=clifton


However, it should also rewrite shorter URIs, e.g.:

http://www.example.com/europe/uk/england/


should become:

http://www.example.com/index.php?id1=europe&id2=uk&id3=england


It all works fine on my live server and in WAMP on my local machine. I just installed openSUSE 11.3 on another computer and found out that this mod_rewrite rule doesn't work there. I am 100% sure mod_rewrite is working fine on this machine since I've tested it with other, simpler rules. I'm thinking perhaps the syntax of the rule isn't right and openSUSE with Apache2 is less forgiving? Any ideas? Thanks.

g1smd

7:53 pm on Nov 21, 2010 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



First off we need to clarify whether you want a redirect or rewrite.

You've used these two terms interchangeably, but they are two completely different things (even though the code for them is very similar).

Jay7

9:04 pm on Nov 21, 2010 (gmt 0)

10+ Year Member



Sorry, I mean URL rewrite.

I found out this fixed the issue:


RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/$ index.php?id1=$1&id2=$2&id3=$3&id4=$4&id5=$5 [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ index.php?id1=$1&id2=$2&id3=$3&id4=$4 [L]
RewriteRule ^(.*)/(.*)/(.*)/$ index.php?id1=$1&id2=$2&id3=$3 [L]
RewriteRule ^(.*)/(.*)/$ index.php?id1=$1&id2=$2 [L]
RewriteRule ^(.*)/$ index.php?id1=$1 [L]


Might not be the best solution but it seems to work.

jdMorgan

4:16 am on Nov 30, 2010 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Server been a bit slow these past ten days when it's busy?

You can significantly speed up your rules by using a much-more-specific pattern.

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2&id3=$3&id4=$4&id5=$5 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2&id3=$3&id4=$4 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2&id3=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/$ index.php?id1=$1&id2=$2 [L]
RewriteRule ^([^/]+)/$ index.php?id1=$1 [L]

And now that the patterns are specific, you are now free to order these rules from most- to least-requested, for a further (if smaller) increase in server performance. Use your server 'stats' to determine which form of URLs are most-requested, and which are least-requested, then order the rules based on that.

Do not use multiple "dot-star" subpatterns unless there is absolutely no other solution. To do so forces your server to do hundreds to tens of thousands of 'back-off-and-retry' pattern-matching attempts for every object requested from your server. Conversely, use of specific subpatterns allows the pattern to be evaluated in a single left-to-right pass.

Jim

Jay7

1:26 pm on Dec 1, 2010 (gmt 0)

10+ Year Member



Thanks Jim, you're a star!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month