本文介绍了htaccess的重定向到子域,并保持串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 发现了一些类似的问题,但无论是我不能算出它的答案,或者他们不直接匹配我的需求。我试图实现是这样的:我最近搬到我的网站的一部分,一个子域不同的服务器上,以便曾经被认为是在: http://mysite.com/clients 现在上 http://clients.mysite.com使用: RedirectMatch 301 HTTPS:(。*)//mysite.com/clients/^ $ https://clients.mysite.com/$1 工作正常对于简单地将人打 http://mysite.com/clients 新的子域名,但是我希望能够preserve后弦/客户机/因此​​,如果有人例如打 http://mysite.com/clients/could_be_a_number_of_things.php 重定向到 http://clients.mysite.com/could_be_a_number_of_things.php谁能指教?根据要求全面的.htaccess: #-FrontPage-IndexIgnore的.htaccess * /。?? *〜*#* / HEADER * * / README * * / _ VTI *&LT;限制GET POST&GT;为了否认,允许所有否认允许所有&LT; /限制&GT;&LT;限制PUT DELETE&GT;为了否认,允许所有否认&LT; /限制&GT;#AuthName mysite.com#AuthUserFile /home/inhost/public_html/_vti_pvt/service.pwd#AuthGroupFile /home/inhost/public_html/_vti_pvt/service.grp#BEGIN字preSS选项​​+的FollowSymLinks -MultiViews&LT; IfModule mod_rewrite.c&GT;RewriteEngine叙述上的RewriteBase /重写规则^指数\ .PHP $ - [L]的RewriteCond%{} REQUEST_FILENAME!-f的RewriteCond%{} REQUEST_FILENAME!-d重写规则。的index.php [L]的RewriteCond%{} HTTPS S上(S)|的RewriteCond%{HTTP_HOST} ^(WWW \)?mysite的\ .COM $重写规则^客户/(.*)$ HTTP%1://clients.mysite.com/$1 [L,NC,R = 301]&LT; / IfModule&GT;#结束字preSS解决方案 到的httpd.conf 启用了mod_rewrite和.htaccess,然后把这个code在的.htaccess $ DOCUMENT_ROOT 目录下的 mysite.com 服务器上: 选项+了FollowSymLinks -MultiViews#开启mod_rewrite的上RewriteEngine叙述上的RewriteBase /的RewriteCond%{} HTTPS S上(S)|的RewriteCond%{HTTP_HOST} ^(WWW \)?mysite的\ .COM $重写规则^客户/(.*)$ HTTP%1://clients.mysite.com/$1 [L,NC,R = 301] Found a few similar questions but either I cant figure it out from the answers or they dont directly match my needs.What I am trying to achieve is this:I recently moved part of my site to a sub domain on a different server so what used to be in: http://mysite.com/clients is now on http://clients.mysite.comusing: RedirectMatch 301 https?://mysite.com/clients/^(.*)$ https://clients.mysite.com/$1 works fine for simply redirecting people hitting http://mysite.com/clients to the new sub domain however I would like to be able to preserve the string after /clients/so if someone hits e.g. http://mysite.com/clients/could_be_a_number_of_things.php it redirects to http://clients.mysite.com/could_be_a_number_of_things.phpCan anyone advise?full .htaccess as requested: # -FrontPage-IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*<Limit GET POST>order deny,allowdeny from allallow from all</Limit><Limit PUT DELETE>order deny,allowdeny from all</Limit>#AuthName mysite.com#AuthUserFile /home/inhost/public_html/_vti_pvt/service.pwd#AuthGroupFile /home/inhost/public_html/_vti_pvt/service.grp# BEGIN WordPressOptions +FollowSymLinks -MultiViews<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]RewriteCond %{HTTPS}s on(s)|RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301]</IfModule># END WordPress 解决方案 Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory on mysite.com server:Options +FollowSymLinks -MultiViews# Turn mod_rewrite onRewriteEngine OnRewriteBase /RewriteCond %{HTTPS}s on(s)|RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$RewriteRule ^clients/(.*)$ http%1://clients.mysite.com/$1 [L,NC,R=301] 这篇关于htaccess的重定向到子域,并保持串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-24 18:48
查看更多