Forum Moderators: phranque
where somecode changes based on the ad
I am using a CMS and mod rewrite to to shorten URLs and remove the index.php file.
My current mod rewrite is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
But if I give the URL [sitename.com?gclid=somecode...]
I get an error page not found.
I am at a loss how to modify the mod rewrite so that
[sitename.com?gclid=somecode...]
still gets processed as [sitename.com...]
I tried changing to
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^/([^/]*)$ /?gclid=$1 [L]
but no luck.
Any mod rewrite experts know this one right off hand
(I am using ExpressionEngine CMS if that makes any difference)
Thanks
It may help you to understand that you are using mod_rewrite to tell the server to deliver content from the "longer" server filepath by adding "/index.php" when the "short" URL+query string is requested by a client (browser or robot), and that what you seem to want to do is to remove the query string "gclid=somecode".
Query strings can be cleared in mod_rewrite by appending a "?" to the substitution path:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/[b]$1?[/b] [L]
Jim