2016-04-14 22 views
1

içinde yönlendirmek için nasıl.Ben başka bir URL'ye URL'den yönlendirmek olacak bir .htaccess dosyası oluşturmanız gerekir</p> <p>... Bu benim ilk kez .htaccess ile çalışıyor ve ben kesinlikle clueless olduğum .htaccess

Kullanıcıların şu URL'yi yazdığını varsayalım: http://localhost/htaccess_test/os/windows/8 ... o zaman, http://localhost/htaccess_test/os/windows/os.php?type=windows&version=8 adresine yeniden yönlendirilirdi.

Ayrıca URL'deki (işletim sisteminin türü ve sürümü) parametrelerin değerlerini listeleyen bir os.php dosyası oluşturmam gerekiyor.

Herhangi bir yardım çok takdir edilecektir!

GÜNCELLEME

.htaccess

RewriteEngine on 
RewriteRule ^os/([^/]+)/([^/]+)$ /os.php?type=$1&version=$2 [R=301,L] 

os.php

<?php 

if(isset($_GET['type']) && isset($_GET['version'])){ 

    echo "Tip OS: " . $_GET['type'] . "<br>"; 
    echo "Verzija OS: " . $_GET['version'] . "<br>"; 
} 
?> 
+0

bir kaynaktır https://github.com/phanan/htaccess – cmorrissey

+0

olduğunu htaccess_test/os/windows/ dizinde bulunmaktadır. html). aynı mı? @cmorrissey – aiden87

+0

Hangi dizinde '.php' dosyalarınız bulunur? – anubhava

cevap

1

htaccess_test/ dizinde bu .htacces oluşturun:

Options -MultiViews 
RewriteEngine On 

RewriteRule ^os/([\w-]+)/(\d+)/?$ os.php?type=$1&version=$2 [L,NC,QSA] 

varsayarsak os.php i bloga index.html den vb html (.html yönlendirmek bilen İşte

+0

Bu klasörde os.php var. Localhost/htaccess_test/windows/8'e gittiğimde 404 hatası bulamıyorum. .htaccess kodunun ve php dosyamın güncellemesini sorunun nerede olduğunu görebiliyor musunuz? – aiden87

+0

http: // localhost/htaccess_test/os/windows/8 yazarken http: //localhost/htaccess_test/os.php? Type = windows & version = 8 dizinine yönlendirme yapmalı mıyım? Bunun php tarafından yapıldığını mu sanıyorsunuz? (sürüm ve tür) ... Ben "os" – aiden87

+0

İLE lütfen güncellenmiş kodumu bakın ... – aiden87