Question:

Help with creating regular expression for mod_rewrite.

by  |  earlier

0 LIKES UnLike

I'm trying to create a mod rewrite rule to change the following "fake" address:

domain.com / directory / subdirectory / product-name /

to:

domain.com / directory / management.php ? variable = product-name

Obviously there are no spaces in the URL, I put them there so they would appear properly in the question without being truncated like a regular link.

I just don't quite get what the regular expression should be. Help would be appreciated--I'm banging my head against the keyboard here.

 Tags:

   Report

1 ANSWERS


  1. -----StartCode-----

    RewriteEngine on

    RewriteRule ^directory/subdirectory/(.*)/$ /directory/management.php?variable=$1

    -----CodeEnd-----

    Above would redirect requests made for the fake url, to the real url.

    The "$1" variable at the end simply contains the content of the parentes "(.*)", the dot "." means any character, and the star "*" means repeated 0 or more times.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions