Forum Moderators: phranque
www.mydomain.com/mavenman
redirecting to
www.mydomain.com/id.php?id=mavenman
using
RedirectMatch ^/(.*[^\.php¦^\.jpg¦^\.gif¦^\.html¦^\.htm¦^/])$ [mydomain.com...]
My question is how can I keep this same working functionality but keep the originating URL in the clients browser location? I assume this needs to be some sort of internal redirection or masking but I have been unable to track down any solution.
TIA for your help!
Mavenman
This code, for use in .htaccess, approximates the function of your RedirectMatch:
Options +FollowSymLinks
RewriteEngine on
# If not php, jpg, gif, html, or html file request or directory request
RewriteCond %{REQUEST_URI} !(\.php¦\.jpg¦\.gif¦\.html?¦./)$
# rewrite the request to id.php with pathname in query string
RewriteRule (.*) /id.php?id=$1 [L]
Options +FollowSymLinks
RewriteEngine on
# If not contains period or forwardslash in REQUEST_URI
#RewriteCond %{REQUEST_URI}!(\.php¦\.jpg¦\.gif¦\.html¦/)$
RewriteCond %{REQUEST_URI}!(\.¦\..*¦/)$
# rewrite the request to id.php with pathname in query string
RewriteRule (.*) /id.php?id=$1 [L]
This simple script in the .htaccess will grab any string that is appended to a top level domain that does not contain a period or a forwardslash (used to trap out filenames and directory calls). This is useful in allowing users to use simple URL's to pass items like usernames or product codes. I have a background id.php file that is processing the string. Once validated, I can process their request accordingly.