Question

I am having error in rewriting url. I want the request http://go.example.com/all-pathnames-flenames

should be handled by some page http://www.example.com/myfile.php

It should not be hard or 301 redirect (rather original url should be there).

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^go\.example\.com$ [NC]
RewriteRule ^(.*)$ /myfile.php [L]

above mentioned is the code i have but it is not working

Was it helpful?

Solution

You need to exclude rewriting myfile.php, otherwise you'll create a loop:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^go\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/myfile.php
RewriteRule ^(.*)$ /myfile.php [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top