Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite with parameter containing slashes

mod_rewrite

         

jason77

7:51 pm on Jun 2, 2004 (gmt 0)

10+ Year Member



Hello mod_rewrite gurus!

I only need a really simply mod_rewrite but I find it really hard. I ended up needing to have 2 slashes...

I am passing a parameter to a script that contains
slashes as the parameter represents a thematic directory branch.

For instance:

intranet.dep/arznei/category.asp? branch=/ext/neu/hormone/mineralkortikoide/aldosteron

the categories can be up to 5 levels.

I am thinking of mapping this category structure to the
url structure to navigate the website more intuitively.

I would like to have a url structure like:

intranet.dep/arznei/hormone/mineralkortikoide/aldosteron

(also to skip the ext/neu bit as it is always the same)

How would you do that?

jdMorgan

2:05 am on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jason77,

Welcome to WebmasterWorld [webmasterworld.com]!

In accordance with our Charter [webmasterworld.com], we can't write the code for you, but if you'll post your best effort and your test results, we *can* help you debug it.

Here are some references to help you get started:

Apache mod_rewrite documentation [httpd.apache.org]
Apache URL Rewriting Guide [httpd.apache.org]
Regular Expressions Tutorial [etext.lib.virginia.edu]

Jim

jason77

6:03 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine On

Rewrite Rule ^arznei/(.*)$ /category.asp?c=/ext/neu/$1

So if I enter:

intranet.dep/arznei/hormone/mineralkortikoide/aldosteron

this should become:

intranet.dep/category.asp?c=/ext/neu/hormone/mineralkortikoide/aldosteron

i havent put it in the previous mail as i wanted to have an unbiassed solution. maybe it is also possible to do it in a completely different way.

Thanks if you could help me!

jdMorgan

6:26 pm on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



jason77,

After removing the space from your "Rewrite Rule" and also adding an [L] flag, this looks fine to me.


Options +FollowSymLinks
RewriteEngine On
RewriteRule ^arznei/(.*)$ /category.asp?c=/ext/neu/$1 [L]

This should work in .htaccess. For use in httpd.conf, add a leading slash to "arznei".

Jim

jason77

9:13 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



Thanks! :-)