search
HomeBackend DevelopmentPHP Tutorial关于网站导航二级域名的问题,纠结很久了

有个问题一直纠结了很久了,一个网站,比如说导航有 动作 喜剧 科幻

对应的是二级域名,我就用我的站来举例,不是广告,

动作现在是:http://www.cuangs.com/Dongzuopian/           应该对应   http://Dongzuopian.cuangs.com 

喜剧现在是:http://www.cuangs.com/Xijupian/                  应该对应   http://Xijupian.cuangs.com

科幻现在是:http://www.cuangs.com/Kehuanpian/            应该对应    http://Kehuanpian.cuangs.com

后面肯定还有很多的比如爱情,悬疑等。

我是不是每一个二级都要去对应的绑定呢,写到这里我都有点晕糊了,就是二级的应该是怎么操作的呢?在线等。


回复讨论(解决方案)

貌似用URL重写就行了。

你的网站 http://www.cuangs.com 并不支持二级域名
请与域名供应商联系开启二级域名解析

你的网站 http://www.cuangs.com 并不支持二级域名
请与域名供应商联系开启二级域名解析


支持哦,我的是VPS,上面有使用过二级的其他站

学习学习

做过类似的,很多地区分站
如果是独立主机不用麻烦,二级域名直接指向根目录,虚拟主机不能省吧
在程序入口获取某个系统变量,加进$_GET,rewrite倒不用

二级域名的控制在于DNS服务商,不在vps供应商,除非两个是同一家
二级域名分主机和跳转两种方式,你这个属于跳转;跳转也分显式和非显式,视乎DNS服务商是否提供,貌似国内不少DNS服务商都不支持显式跳转
上面的东西又不明白去wiki一下

如果支持的话,http://dongzuopian.cuangs.com 就应该访问到(哪怕是错误的页面)而不是提示域名错误

泛解析。这个还真没搞过,原先做的是Win IIS 直接一个个手动绑定,那个麻烦啊,linux下不知道是如何操作。

其实没啥神秘的,三步搞定
1域名做一下泛解析就是  *.域名  然后单独绑定一个主机头的站点
2通过用户的 $_SERVER[''HTTP_HOST'] 获取当前访问的域名
3根据当前访问的域名获取到用户名,再获取其他信息。

嗯,泛解析是可以,还有根据$_SERVER[''HTTP_HOST'] 这个一起结合也可以,谢谢大家,搞掂。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function