SUSE LINUX Enterprise & openSUSE Community
กรกฎาคม 23, 2019, 06:41:27 PM *
ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

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

[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. 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  (อ่าน 2038 ครั้ง)
0 สมาชิก และ 2 บุคคลทั่วไป กำลังดูหัวข้อนี้
Expert : ผู้เชี่ยวชาญ

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

กระทู้: 1931


« เมื่อ: พฤศจิกายน 18, 2013, 12:51:38 PM »

How to configure url redirection with apache

SUSE Linux Enterprise Server
How to configure apache for url redirection from to
New Domain/DNS address. Need to configure old URL to redirect to new domain address.
Migrated domain's url address.
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 (

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

In the example below, any requests that come in to are forwarded to

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 (the unpreferred url).

Note: When users access, 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

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
Edit /etc/apache2/listen.conf:

Replace Listen 80 with Listen <ipAddress>:80
For example: Listen

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

6. Configure URL redirection using .htaccess:

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

RedirectMatch 301 ^(.*)$

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 to the 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 วินาที กับ 22 คำสั่ง (Pretty URLs adds 0.007s, 2q)