我工作的一個網頁(姑且稱之爲example.com),並加入下CNAME(別名)的DNS記錄:使www.example.com和example.com使用相同的會話變量的最佳方式是什麼?
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 [email protected]
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。 – lonesomeday
爲什麼你首先有兩個變化?將一個人重定向到另一個人會不會更有意義? –
由於寂寞天寫道,你應該使用301重定向(.htaccess),因爲所有的搜索引擎將把這個網站視爲2個不同的網站,在搜索結果中,你可以有2個不同的鏈接到同一頁面,這是不對的。它對谷歌和其他人的定位非常重要。 – miszczu