PDA

View Full Version : htaccess problem


Red Blaze
07-15-2009, 03:36 PM
I only know so much about htaccess, and my researching isn't really helping me get closer to the finish line. I'm having an issue and I'm very confused about its behavior.

Take a look at this htaccess code I have set up:
Notice, I added comments that pin point which rules are acting odd. Total of 3 lines, but they're all similar.

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^Home$ /index.php [L]
RewriteRule ^Search$ /search.php [L]

#Searching through Category
RewriteRule ^Search/Category/(.*)$ /search.php?act=dosearch&jobtype=$1&boolean=any&date=all&exempt=all&perpage=5&country=US&searchType=category&searchType=category [L]
#This is one of the rules that are acting odd
RewriteRule ^Search/Category/(.*)/([0-9]+)-([0-9]+)$ /search.php?act=dosearch&jobtype=$1&boolean=any&date=all&exempt=all&perpage=$2&start=$3&country=US&searchType=category [L]

#Searching through location
RewriteRule ^Search/City/(.*)/(.*)$ /search.php?act=dosearch&jobtype=all&boolean=any&date=all&exempt=all&perpage=5&country=US&location=$1|$2&searchType=location [L]
#This is one of the rules that are acting odd
RewriteRule ^Search/City/([^/]+)/([^/]+)/([0-9]+)-([0-9]+)$ /search.php?act=dosearch&jobtype=all&boolean=any&date=all&exempt=all&country=US&location=$1|$2&perpage=$3&start=$4&searchType=location [L]

#Searching through company
RewriteRule ^Search/Company/([0-9]+)/(.*)$ /search.php?act=dosearch&jobtype=all&boolean=any&date=all&exempt=all&perpage=5&country=US&companyId=$1&companyName=$2&searchType=company [L]
#This is one of the rules that are acting odd
RewriteRule ^Search/Company/([0-9]+)/([^/]+)/([0-9]+)-([0-9]+)$ /search.php?act=dosearch&jobtype=all&boolean=any&date=all&exempt=all&perpage=$3&start=$4&country=US&companyId=$1&companyName=$2&searchType=company [L]

RewriteRule ^Job/(.*)$ /job.php?jid=$1 [L]



The problems lie when searching through location, category and company, but when trying to look at the 2nd page of the results. Here's the page(s) I'm working on that's using that part of the htaccess rules.

http://gagajobs.astralaxiom.net/Search/City/Harlingen/TX

However, when trying to see the second page of the results:
ex: http://gagajobs.astralaxiom.net/Search/City/Harlingen/TX/5-5

You can see the array of requests when viewing those pages.

It's parameters are acting strangely. $1 should be Harlingen, $2 should be TX, $3 should be 5 and $4 should be 5. Unless I did something wrong in the code, which is exactly what I'm looking for in my researching... but the tutrials I've found and examples I've run into do not explain anything about using more than 2 parameters. Help and advice would greatly be appreciated.

------------------------

I'm still researching while I wait for some help, and I've tried so many other formats, such as:

RewriteRule ^Search/Company/([^/\.]+)/([^/\.]+)/([^/\.]+)-([^/\.]+)$
RewriteRule ^Search/Company/([0-9]+)/([^/\.]+)/([0-9]+)-([0-9]+)$
RewriteRule ^Search/Company/([0-9]+)/([^/.]+)/([0-9]+)-([0-9]+)$

But they all behave the same way... the results end the same. So confused. x.x

---------------------------

I found the problem... Like Conan from Case Closed says... "I can't believe I didn't see it before." The problem was "(.*)". I noticed that after clicking "Next x Results", the URL kept adding "5-5/5-5/5-5" and it was still the first page. So I changed all (.*) to a more specific... parameter? It's working like a charm, now.

If anyone took the time to look into it, thank you.