문제

I wonder how to redirect links with .htaccess.

One domain links http://domain.com to index.html, and another http://www.domain.com to /wp/index.php.

When someone types www.my-domain.com in the browser. I want that domain with www. to redirect to one one file, for example /unique/one.php. And when someone types my-domain.com without www., that should redirect to another file in my directory, for instance /another/index.php.

Any solutions for this problem?

도움이 되었습니까?

해결책

put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^/?$ /wp/index.php [L]

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^/?$ /index.html [L]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top