关于htaccess,二级域名的问题,在线等
各位早上好,遇到的问题是
网站,有二级域名,现在可以正常访问,但是不带www的却访问到二级的去了,
以下为.htaccess代码
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.518visa.net$
RewriteCond %{REQUEST_URI} !^/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1
RewriteCond %{HTTP_HOST} ^www.518visa.net$
RewriteRule ^(/)?$ / [L]
#以下为二级,如果有更简单的希望指教,谢谢
RewriteCond %{HTTP_HOST} ^([A-Za-z]*[^www\b]).518visa.net$
RewriteCond %{REQUEST_URI} !^visalist/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^([A-Za-z]*[^www\b]).518visa.net$
RewriteRule ^([1-9]\d*).html($) visalist/visa_detail.php?id=$1
RewriteRule ^(/)?$ visalist/ [L]
网址为www.518visa.net,非外链广告,麻烦看看,谢谢了。
下图红框选中的,点进去为二级域名
我现在需要的就是不带www访问时直接转到带www,如abc.com/a.html转到www.abc.com/a.html,我用了
RewriteCond %{HTTP_HOST} !^www.518visa.net$ [NC]
RewriteRule ^(.*)$ http://www.518visa.net/$1 [L,R=301]
这个也不行
谢谢了,在线等
回复讨论(解决方案)
我用的是如下:
#301RewriteCond %{HTTP_HOST} ^xxx.net [nc]RewriteRule ^(.*)$ http://www.xxx.net/$1 [L,R=301]#aaaa.xxx.net - is OKRewriteCond %{HTTP_HOST} (?!www|ww)^[a-z0-9\-]+.xxx.net$RewriteRule ^/?$ /%{HTTP_HOST}RewriteRule ^/([a-z0-9\-]+).xxx.net$ /1.php?keyword=$1
如果不行, 你看看你的apache里面的documentroot设置了什么
如果还不行, 你可以考虑用变通的方法。
建立一个xxx.net的web,然后在这个web里面做一个htaccess 301到www

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to use Laravel to develop an online restaurant reservation system In recent years, with the rapid development of the Internet and mobile Internet, online reservations have become an indispensable part of modern people's lives. The catering industry is no exception. More and more restaurants are beginning to provide online reservation services to improve user experience and expand market share. This article will introduce how to use the Laravel framework to develop a simple but fully functional online restaurant reservation system, and provide specific code examples to facilitate readers to learn and practice. Environment setup First, we need

How to use JavaWebsocket to implement online audio and video calls? In today's digital age, real-time communication is becoming more and more common. Whether it is remote collaboration at work or remote communication with relatives and friends at home, real-time audio and video calls have become an indispensable part of people. This article will introduce how to use JavaWebsocket to implement online audio and video calls, and provide specific code examples. 1. Understand WebsocketWebsocket is a new technology in HTML5

How to use PHP to implement a simple online music player. With the advent of the digital age, more and more people are beginning to enjoy music through the Internet, and online music players have become an important tool. In this article, we will implement a simple online music player through the PHP programming language and provide specific code examples. Preparation work: Before starting, we need to prepare the following aspects: a machine running a web server (such as Apache). PHP running environment. Music files, music files can be

With the popularity of e-commerce, more and more businesses are adopting online invoice management systems to manage sales and invoices. When developing an online invoice management system, it is important to choose the right tools and technology. This article will introduce how to use PHP language to develop an online invoice management system and provide some useful development guidelines. Determine system requirements Before starting development, the specific requirements for an online invoice management system need to be determined. This may include the following aspects: Invoice management: saving, querying and editing invoice information; Customer information management: saving, querying and editing customers

How to use Laravel to develop an online customer service system Introduction: Online customer service systems play an important role in modern enterprises. It helps businesses communicate with customers in real time, answer questions, provide support, and enhance user experience. This article will introduce how to use the Laravel framework to develop a simple and practical online customer service system. 1. Design the database The online customer service system needs to store users and conversation records, so it is first necessary to design a suitable database model. In Laravel we can use the migration tool

How to use PHP to implement a simple online event registration system. With the rapid development of the Internet, more and more activities are beginning to manage the registration process through online registration systems, eliminating the trouble of traditional paper registration forms and manual processing. This article will introduce how to use PHP language to implement a simple online event registration system, and use specific code examples to help readers understand and practice. System Requirements Analysis Before developing a system, it is first necessary to clarify the requirements and functions of the system. According to the characteristics of the event registration system, we can determine the following

How to use PHP to implement a simple online order management system 1. Introduction Online order management system is a common e-commerce application. It can help merchants effectively manage the order process, speed up order processing, and improve customer satisfaction. This article will introduce how to use PHP to implement a simple online order management system, including the creation, modification, query and deletion of orders. This article assumes that readers already have some basic knowledge of PHP. 2. System Requirements The online order management system needs to meet the following basic requirements: Login function

Application steps: 1. Enter the domain name registration service website, register an account and log in; 2. Select the "Domain Name Registration" service, enter the second-level domain name you want to register, and click Query; 3. If the second-level domain name has not been registered, then You can click the "Register Now" button to register; 4. On the registration information page, fill in the domain name owner's name, contact number, email and other information, and set a password; 5. Confirm the payment method and complete the payment; 6. Wait for the official Review generally takes 1-5 working days.
