的.htaccess重写多个URL重定向没有

编程入门 行业动态 更新时间:2024-10-28 04:28:13
本文介绍了的.htaccess重写多个URL重定向没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

好了,所以我有这样的URL,这些demo1.domain,demo2.domain,demo3.domain和所有需要显示的子文件夹的内容,这样的例子 demo1.domain将显示domain/websites/demo1的内容 我需要做的是在所有的领域,比如$ whatever.domain到domain/websites/$whatever.domain,我已经启用了DNS通配符的方式,而我似乎无法fiqure出来,请大家多记住我不希望它重定向。

Ok so i have urls like these demo1.domain, demo2.domain, demo3.domain and all needs to show the contents of a subfolder like this example demo1.domain will show the contents of domain/websites/demo1 i need to do it in a way that all the domains like $whatever.domain into domain/websites/$whatever.domain, i already enabled wildcard dns, and i cant seem to fiqure it out, please keep in mind i dont want it to redirect.

下面是我试过

RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www\.)?[^.]+\.domain\.*$ RewriteRule /websites/$1 [L]

我刚刚得到domain的主页与此有关。

I just get the main page of domain with this.

您的帮助将大大AP preciated。

Your help will be greatly appreciated.

推荐答案

关闭,试试这个:

RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !^/websites/ RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+\.domain\.*)$ [NC] RewriteRule ^(.*)$ /websites/%2/$1 [L]

请注意,这只会工作,如果所有的演示* .domain 指向同一个文档根目录作为主域( domain )

Note that this will only work if the all the demo*.domain point to the same document root as the main domain (domain).

更多推荐

的.htaccess重写多个URL重定向没有

本文发布于:2023-11-01 19:40:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550227.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   重写   重定向   htaccess   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!