问题
How can i rewrite the domain url to a specific domain name if it didnt match it ..
Let's say i want it to only match example.com
and the visitor came from server ip (http://127.0.0.1/something/else) OR came from another domain (http://domain.com/something/else)
how can i rewrite the domain name and keep all the other parameters, just domain name to example.com ( result should be : http://example.com/somthing/else )
回答1:
Try adding these rules to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R]
来源:https://stackoverflow.com/questions/13021893/htaccess-mod-rewrite-hostname