View Full Version : mod_rewrite with string variable

10-12-2011, 03:20 AM
I don't even think I have the topic title right...it's almost no wonder I'm lost

the long and short is I need to have a single landing page that will be branded with each affiliate's banner...when I present this to them tomorrow, I want to be able to say "ok guys...all you need to do is send your agents to http://domain.com/affiliateshortname/carrier" so that they can download whatever documents they need

in so many tutorials this is demonstrated as something like:
RewriteRule ^[A-Za-z]/heartland/quick-quote.html$ /heartland/index.php?affiliateID=$1 [L]

and then I'll be able to get the appropriate header banner to display based on affiliateID

how can I get [A-Za-z] turned into $1 I think is what I'm asking

as always any help is greatly appreciated

10-12-2011, 04:18 AM
This hasn't a thing to do with PHP, moving to apache configurations.
Wrap the [A-Za-z] in brackets. PHP will then be provided an affiliateID of that value found in the $_GET superglobal.

10-12-2011, 04:54 AM
thanks for getting me in the right topic :)

ok so then I did have it kind of right...now I'm just getting 404 errors

the actual link that I will be providing my guys is http://mynsga.com/aam/heartland/quick-quote.html (aam is one of the affiliate short names) - I have tried to access it by typing that url in the address bar and by clicking on a link (<a href="/aam/heartland/quick-quote.html">blah</a>) and they both generate a 404 error

so this is what I have in my .htaccess:

ErrorDocument 400 /includes/config.php
ErrorDocument 401 /includes/config.php
ErrorDocument 403 /includes/config.php
ErrorDocument 404 /includes/config.php
ErrorDocument 500 /includes/config.php

RewriteEngine on
RewriteRule ^[A-Za-z]/heartland/quick-quote.html$ /heartland/index.php?affiliateID=$1 [L]

is it possible that mod_rewrite isn't available to me? could someone tell me what I need to look for in my phpinfo() to see if it's enabled? if it's not enabled then all of this is an exercise in futility as I don't have access to the httpd.conf file or whatever (although it's good stuff to learn anyway :rolleyes: )

thanks in advance for your help :)

EDIT: just wanted to add that according to GoDaddy:

Mod_rewrite is an Apache Web server module installed on all of our Linux servers by default; it does not have to be installed or enabled. Our Linux hosting accounts support most mod_rewrite functions.