i have sub-site named subsite.site.com
(just and example). firstly i want to redirect subsite.site.com
to www.subsite.site.com
and and finally i want to redirect www.subsite.site.com
to www.subsite.site.com/directory/subdirectory/index.html
the following rewrite conditions & rules serve this purpose independently.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^subsite.site\.com
RewriteRule ^(.*)$ http://www.subsite.site.com/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.subsite\.site\.com$
RewriteRule ^/?$ "http\:\/\/www\.subsite\.site\.com\/directory\/subdirectory\/" [R=301,L
how shall i combine the above two conditions & rules in a single .htaccess
file?
thanks,
how shall i combine the above two conditions & rules in a single .htaccess file?
Just put one after the other in the same file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.subsite\.site\.com$ [NC]
RewriteRule ^/?$ /directory/subdirectory/ [R=301,L]
RewriteCond %{HTTP_HOST} ^subsite.site\.com [NC]
RewriteRule ^(.*)$ http://www.subsite.site.com/$1 [R=301,L]
来源:https://stackoverflow.com/questions/17501235/how-to-write-multiple-rewrite-conditions-and-rules-in-one-htaccess-file-for-red