Search
Left Quote    I have not failed. I've just found 10,000 ways that won't work.
- Thomas Alva Edison    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Mod Rewrite - Server loops
  This user is offline  sm0ke
  Subject: "Mod Rewrite - Server loops" Posted: @ 11:09 am on Oct 26 2006   

Member #: 168
Rank: User - (83)
Since: 06/05/06
Posts: 34
From: Manchester - UK

Hi

I just need to know if the rewrite rule im using is ok, IE - not sending the server into a loop.

I'm using the following rule:

RewriteRule ^(.*)/(.*)/*$ cat.php?rel=$1& amp;part=$2

It works, but I'm aware of problems arising with differing rules if they work or not.

Can anyone see a problem with this rule?


Just because I dont care, doesnt mean I dont understand.
purepcs@hotmail
.co.uk |     Viewed: 5,986 Times | Reply to This | To top
  This user is offline  sm0ke
  Subject: "re: Mod Rewrite - Server loops" Posted: @ 1:19 pm on Oct 26 2006    

Member #: 168
Rank: User - (83)
Since: 06/05/06
Posts: 34
From: Manchester - UK

I found a problem

When accessing the site

www.domain.com/ sub

its seen as a bad request, however adding a "/" so it would be

www.domain.com/ sub/

works fine, changing the rule to read

RewriteRule ^sub/(.*)/(.*)/ *$ cat.php?rel=$1& amp;part=$2

means I can access

www.domain.com/ sub

with no problems, but in accessing the cat.php page, the url has to be constructed:

ww.domain.com/s ub/sub/rel/part

using "/sub/sub /" isnt really ideal as it overcomplicates the url.

The only problem I have is when someone wants too type the domain directly and not follow a link, they may not type the trailing "/"

Any ideas on a fix for this one?




Just because I dont care, doesnt mean I dont understand.

purepcs@hotmail
.co.uk |     Viewed: 5,976 Times | Reply to This | To top
  This user is offline  misterhaan
  Subject: "re: Mod Rewrite - Server loops" Posted: @ 4:06 pm on Oct 26 2006    

Member #: 5
Rank: User - (213)
Since: 02/11/05
Posts: 148
From: chair

if that's the only rule you're using then it's not going to get into a loop, so you're fine there. i don't quite understand your second post though.

www.domain.com/ sub is looking for a file (no trailing /), but generally when sub is actually a directory, the slash gets added automatically (i think apache sends back a location header telling the browser to try /sub/ instead of /sub). so i'm not sure why you get a bad request on that. is it actually an http bad request error, or do you mean something else?

i'm also not sure why you would need /sub/sub/ -- is your rewrite rule inside /sub/? if so, you can actually move it up a level and then just update the cat.php part to make sure it finds the right file (i.e .change it to sub/cat.php).




please note that the above post is likely made up in its entirety.

    Viewed: 5,970 Times | Reply to This | To top
  This user is offline  sm0ke
  Subject: "re: Mod Rewrite - Server loops" Posted: @ 12:33 am on Oct 27 2006    

Member #: 168
Rank: User - (83)
Since: 06/05/06
Posts: 34
From: Manchester - UK

misterhaan

thanks for the reply / advice. in regards to the first post, i wasnt sure about having a wildcard as the first section of the rule - something i read somewhere at somepoint.

sub is actually a directory of its own and the .htaccess file is / was placed here with the rules for that directory. I do receive a http bad request error when acessing the sub without the trailing slash but this may be down to the apache config on the server (servage - many problems) but im unsure.

Thanks for the advice.




Just because I dont care, doesnt mean I dont understand.

purepcs@hotmail
.co.uk |     Viewed: 5,963 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank