SUSE LINUX Enterprise & openSUSE Community
มกราคม 18, 2019, 04:52:46 AM *
ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน
ส่งอีเมล์ยืนยันการใช้งาน?

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น
ข่าว:
 
   หน้าแรก   ช่วยเหลือ ค้นหา เข้าสู่ระบบ สมัครสมาชิก  

[Why we need your support] SUSE and openSUSE are trademarks of Attachmate Group, Inc. - WE ARE NOT IN ANY WAY ASSOCIATED WITH SUSE AND ATTACHMATE GROUP. SUSEThailand.com is a SUSE Linux user and community found in Thailand but not limited to other country suse linux user to join in. Currently active contents (How to's, Scripts, Tips, Tricks, Tutorials, Linux Command Line, and Troubleshooting) this suse linux how to's and expert support are SUSE Linux.
หน้า: [1]   ลงล่าง
  พิมพ์  
ผู้เขียน
หัวข้อ: How to configure url redirection with apache  (อ่าน 1858 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
Sontaya
Administrator
Expert : ผู้เชี่ยวชาญ
*****

Karma: +1/-0
ออฟไลน์ ออฟไลน์

กระทู้: 1931


Administrator


เว็บไซต์
« เมื่อ: พฤศจิกายน 18, 2013, 12:51:38 PM »


How to configure url redirection with apache

Environment
SUSE Linux Enterprise Server
 
Situation
How to configure apache for url redirection from http://www.domain.com to http://www.new-domain.com
New Domain/DNS address. Need to configure old URL to redirect to new domain address.
Migrated domain's url address.
 
Resolution
Here are a couple definitions that should be understood before proceeding:

1. What is referred to below as the new domain is the domain URL that is the replacement or preferred address (www.new-domain.com).

2. The new or secondary IP address is to be associated with the old or unpreferred domain address or URL (www.domain.com).

In the example below, any requests that come in to www.domain.com are forwarded to www.new-domain.com:

1. Add a secondary IP address to the server. YaST | Network Settings.
Note: This presumes both URLs or domains resolve to the same address. Separate IP address are needed to manage proper url redirection on the same server.

2. Configure DNS to point this new IP address to www.domain.com (the unpreferred url).

Note: When users access www.domain.com, they are directed to this new IP address, which in the following steps will be handled by a new instance of apache that will redirect the request to the preferred domain address or URL www.new-domain.com.

3. Install apache on the server:

YaST | Software Management
Select Patterns. From the left panel under Primary Functions, select Web and LAMP Server.
Check apache2 and select Accept.
Proceed with Installation and Configuration.
Note: If possible, configure apache to to Listen only with the new network address from Step 1 and on port 80; however, this is covered manually in the next Step.

4. In order to receive these requests, configure apache to listen on the new IP address, port 80 only:
Note: If this is already configured from Step 3, you can skip this section. The goal is to get apache to listen on the new IP address only (the one created in Step 1), not interfering with the current IP address already associated with www.new-domain.com.
Edit /etc/apache2/listen.conf:

โค๊ด:
Replace Listen 80 with Listen <ipAddress>:80
For example: Listen 151.155.215.91:80

Note: This is the new IP address used in Step 1.
Save and Close file.

5. Configure apache to allow the .htaccess file:
Edit /etc/apache2/httpd.conf and append the following to the very end:

โค๊ด:
# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

6. Configure URL redirection using .htaccess:

Create a new file in /srv/www/htdocs/ called .htaccess with the following contents:

โค๊ด:
RedirectMatch 301 ^(.*)$ http://www.new-domain.com

Save and Close the file.
Configure permissions of .htaccess:

โค๊ด:
chmod 775 .htaccess

Note: This redirects any incoming requests to this new apache instance (any requests to http://www.domain.com) to the http://www.new-domain.com. We use a 301 redirect because it is a Moved Permanently redirection. Google recommends using a 301 redirect to change the URL as it is shown in search engine results [1]. If this is not a permanent domain redirection, but rather a temporary one, consider using a 302 redirect.

7. Restart apache:

โค๊ด:
rcapache2 restar

Reference: Support TID
แจ้งลบกระทู้นี้หรือติดต่อผู้ดูแล   บันทึกการเข้า

ageLOC Technology
หน้า: [1]   ขึ้นบน
  พิมพ์  
 
กระโดดไป:  

(@)2007 SUSE Linux user community found in Thailand. This site is not an official openSUSE and SUSE website, and is not in any way affiliated with or endorsed by SUSE Linux GmbH or Novell. openSUSE and SUSE are trademarks of Novell, Inc. in the United States and other countries.
Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!
หน้านี้ถูกสร้างขึ้นภายในเวลา 0.032 วินาที กับ 19 คำสั่ง (Pretty URLs adds 0.008s, 2q)