i want to make a htaccess to have a short link

对着背影说爱祢 提交于 2020-01-05 22:28:50

问题


just wish to present this long link login.mydomain.com/myusersaccount/loginaccount/login.php, to this login.mydomain.com, so that when i access login.mydomain.com/myusersaccount/loginaccount/login.php, it take me to this login.mydomain.com, here is the code i use in htaccess:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^ %{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]

RewriteCond %{HTTP_HOST} ^login\.mydomain\.com$ [NC]
RewriteRule ^$ http://login.mydomain.com/myusersaccount/loginaccount/login.php [R=301,L]

RewriteCond %{HTTP_HOST} !^login\.mydomain\.com$ [NC]
RewriteRule ^myusersaccount/loginaccount/login\.php$ http://login.mydomain.com {REQUEST_URI} [NE,R=301,NC,L]

RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC]
RewriteRule ^$ http://www.mydomain.com/ [NE,R=301,L]

回答1:


Remove the R flag from this rule like this:

RewriteCond %{HTTP_HOST} ^login\.mydomain\.com$ [NC]
RewriteRule ^$ /myusersaccount/loginaccount/login.php [L]


来源:https://stackoverflow.com/questions/20951304/i-want-to-make-a-htaccess-to-have-a-short-link

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!