Forum Moderators: phranque

Message Too Old, No Replies

Applying mod rewrite to files in folders

         

Tom_Cash

3:35 pm on Nov 25, 2010 (gmt 0)

10+ Year Member



Hey Peeps,
Mod_rewrite isn't one of my strong points and I've recently been doing a lot of discovery and now I'm stuck.

I want the following code to work from the root directory.

# /search term / category id / manufacturer id / page number
RewriteRule ^/?([a-zA-Z0-9_]+)/([0-9_]+)/([0-9_]+)/([0-9_]+)$ index.php?c=$1&cat=$2&man=$3&p=$4 [L]


It works a treat inside the required folder. However, I can't get it to work from the root, as mentioned.

I've tried a couple of things, such as the following:

# /search term / category id / manufacturer id / page number
RewriteRule ^advanced_search/([a-zA-Z0-9_]+)/([0-9]+)/([0-9]+)/([0-9]+)$ advanced_search/index.php?c=$1&cat=$2&man=$3&p=$4 [L]


But I have to be honest... I don't completely understand how this works and can't solve my problem.

This is my file structure:

root
- .htaccess
- /advanced_search
--- index.php

Any help people could offer would be greatly appreciated!

Cheers,
Tom.

g1smd

9:01 pm on Nov 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What does "does not work" mean?

What URL did you test?
What was the result?
What HTTP status code was returned? (Use Live HTTP Headers to check this.)

jdMorgan

5:36 pm on Dec 1, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming that the "/advanced_search" subdirectory and this .htaccess code are both located in the top-level directory, then your code should have worked. Did you delete your browser cache before testing in order to avoid seeing stale/cached server responses?

Jim