debugitbob
asked on
Htaccess url redirect change asp to php and pass url params
Here is what I want to do. goes to template.asp?TemplateID=## I want them to get redirected to template.php?aid=##
This is what I want to put into my htaccess file will the last 2 strings work?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^TemplateID=([0-9])$
RewriteRule template\.asp template\.php\?aid=%1/? [R=301]
This is what I want to put into my htaccess file will the last 2 strings work?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^TemplateID=([0-9])$
RewriteRule template\.asp template\.php\?aid=%1/? [R=301]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so what I want is when someone goes to dentalcomfortzone.com//tem plate.asp? TemplateID =88 I want them to get redirected to dentalcomfortzone.com/temp late.php?a id=88
try this for the last line:
RewriteRule template\.asp\?TemplateID= ([0-9]*) redirect.php?aid=%1 [R=301]
also check your log to see if one of the lines is considered broken.
RewriteRule template\.asp\?TemplateID=
also check your log to see if one of the lines is considered broken.
> .. will the last 2 strings work?
no
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^TemplateID=([0-9]*)$
RewriteRule template\.asp template.php?aid=%1 [R=301]
If you want to have the query string also, you need to add the QSA flag.
Keep in mind that this rule matches template.asp anywhere in the path.
no
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^TemplateID=([0-9]*)$
RewriteRule template\.asp template.php?aid=%1 [R=301]
If you want to have the query string also, you need to add the QSA flag.
Keep in mind that this rule matches template.asp anywhere in the path.
ASKER
Here is the full file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^TemplateID=([0-9]*)$
RewriteRule template\.asp?TemplateID=(
ErrorDocument 404 http://www.dentalcomfortzone.com/inthenews.php