www.webdeveloper.com
Results 1 to 4 of 4

Thread: Need help with RewriteRule

  1. #1
    Join Date
    May 2004
    Posts
    167

    Cool Need help with RewriteRule

    Hello,

    I have a. .htacces file with the following rule:

    PHP Code:
    RewriteRule ^([A-Z]{5})$ dir/myfile.inc.php?profile=$[L
    What it does is checks the URL and if the link looks like:

    http://domain.com/ABCDE it takes the last part of the URL and redirects to the dir/myfile.inc.php.

    I need to modify RewriteRule to add additional parameters to it but make it work as it does now. For example,

    Basically keep additional params for the sake of SEO but keep the functionality as is.

    Not sure how to do this...

  2. #2
    Join Date
    Sep 2008
    Posts
    408
    ([A-Z]{5}) can become ([a-zA-Z0-9_-/]+), which would catch letters, numbers, underscores, hyphens, and slashes. Which would make $_GET['profile'] = 'ABCDE/additional/parameter' in your example and would need to be split() accordingly.

    Or can do something like this:
    Code:
    ^([A-Z]{5})/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)[\/]$ dir/myfile.inc.php?profile=$1&addition=$2&parameter=$3 [L]

  3. #3
    Join Date
    May 2004
    Posts
    167
    Ah, great.

    What if I only need the first value to be all CAPS, 5 chars in length and the rest of the parameters are there just for the sake of SEO. Do I need to do anything with the flags?

  4. #4
    Join Date
    Sep 2008
    Posts
    408
    If you only need the first flag:
    Code:
    ^([A-Z]{5})(.*)$ dir/myfile.inc.php?profile=$1&

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles