0

I want to redirect with .htaccess any of the following:

http://domain.com/folder
http://domain.com/folder/
http://domain.com/folder/index.html
http://domain.com/folder/index.php

to

http://another-domain.com/file.php?var=xyz

I did understand how to rewrite file-to-file or folder-to-folder, but I'm missing how to redirect from a folder to other domain's file URL

Thank you

1 Answer 1

1

Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^folder(/.*|)$ http://another-domain.com/file.php?var=xyz [L,NC,R=301]

Suggested Reading: Apache mod_rewrite Introduction

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.