Can you please explain substitution in RewriteRule
Posted
by
Scott
on Server Fault
See other posts from Server Fault
or by Scott
Published on 2013-08-13T15:55:50Z
Indexed on
2013/11/09
21:57 UTC
Read the original article
Hit count: 284
apache2
|mod-rewrite
I have the following statements in an .htaccess file
RewriteCond %{HTTP_HOST} ^myOldDomain\.com$ [NC]
RewriteRule ^(.*)$ https://myNewDomaink.com/$1 [R=301,L]
It works fine. I basically found some sample code and modified it to my specific purpose. What I don't quite understand is:
Why does $1 refer to the the portion of the supplied url after the hostname - where is the documentation for this? There is no backreference in the RewriteCond.
© Server Fault or respective owner