Questions about htaccess and second-level domain names, online, etc.

Source: Internet
Author: User
For questions about htaccess and second-level domain names, good morning for everyone online. what's the problem?
The website has a second-level domain name. now it can be accessed normally, but it has been accessed to level-2 without www,
The. htaccess code is as follows:
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]
# The following is Level 2. if you have more simple suggestions, thank you.
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 * pai.html ($) visalist/visa_detail.php? Id = $1
RewriteRule ^ (/)? $ Visalist/[L]

The website is www.518visa.net. it is a non-External link advertisement. Please check it out. thank you.
Selected in the red box. click it to enter the second-level domain name.


What I need now is to directly transfer www without www access, such as abc.com/a.htmlto www.abc.com/a.html. I use
RewriteCond % {HTTP_HOST }! ^ Www.518visa.net $ [NC]
RewriteRule ^ (. *) $ http://www.518visa.net/#1 [L, R = 301]
This cannot be done either.
Thanks, online, etc.


Reply to discussion (solution)

I use the following:

#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


If not, check what documentroot has set in your apache.
If not, consider using a work und.
Create a xxx.net web, and then create an htaccess 301 to www

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.