簡體   English   中英

使www.example.com和example.com使用相同會話變量的最佳方法是什么?

[英]Best way to make www.example.com AND example.com use the same session variables?

我正在開發一個網頁(讓我們稱之為example.com)並在CNAME(Alias)下添加DNS記錄:

Host Record Points    to  TTL
www  example.com       14400

但是,當我瀏覽example.com時,如果我訪問www.example.com,則不會保留設置的會話變量

使www.example.com和example.com使用相同的會話變量的最佳方法是什么?

我正在使用ubuntu 12.04,php5,apache2。

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName www.example.com
    Redirect 301 / http://example.com/
    DocumentRoot /var/www/public_html
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/public_html>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

使www.mysite.com和mysite.com使用相同的會話變量的最佳方法是什么?

最好的方法是不要讓兩個主機名都運行相同的站點。

選擇其中一個為規范,然后將所有內容從另一個重定向到規范的。

<VirtualHost *:80>
ServerName example.com
Redirect 301 / http://www.example.com
etc

你應該去的最好的方法是將mysite.com重定向到www.mysite.com ,反之亦然 - 只為域別名提供一個站點(一個內容)...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM