Çıkarın. PHP ile php uzantısı

4 Cevap php

Ben burada biraz yardım kullanabilirsiniz. Benim URL'yi düzeltmek için bu kullanıyorum ama. Php uzantısını kaldırmak için nasıl anlamaya olamaz. http://mydomain.com/page.php/foo/123/bar/456: URL bu şimdi benziyor

function decode_URL_parameters() {
   $path = @$_SERVER['PATH_INFO'];
   $url_array=explode('/',$path);

   array_shift($url_array);

   while ($url_array) {
      $_GET[$url_array[0]] = $url_array[1];
      array_shift($url_array);
      array_shift($url_array);
   }
}

Herhangi bir fikir?

/ Tobias

4 Cevap

Apache ile hizmet ediyorsanız, mod_rewrite bakmak isteyeceksiniz.

mod_rewrite, URL'leri uygulamanın gerçek uç noktaları eşleştirilir nasıl değiştirebilirsiniz kullanma. Lütfen Örneğin, böyle bir şey isteyeceksiniz:

RewriteEngine on 
RewriteRule ^/?page/(.*)$ page.php/$1 [L]

This page diğer bazı basit örnekler vardır.

Muhtemelen php. Php uzantısına sahip dosyaları için tüm istekleri işlemek bildirmek için web sunucusu yapılandırılmış. Adlı bir apache var varsayalım. Sonra gibi bir şey var

AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt

veya

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

in one of the configuration files. The second one tells the apache that all files that match the mask .php$ should be handled by the module/handler that registered fveyathe type application/x-httpd-php (php).
But you don't have to limit it to .php files. You can use any file mask you want. Or another directive like e.g. <Directory>.
If all files in a specific directory (and maybe its subdirectories) are php scripts you can even put an .htaccess file in that directory with

ForceType application/x-httpd-php

ve apache php komut dosyası gibi herhangi bir dosyayı tedavi edecek. ForceType önceki İşleyici ayarlarını geçersiz kılar.

Apache altında, page.php dosyasını içeren dizinde bir. Htaccess dosyasını koydu.

. Page.php dosyaları kök dir (yani / page.php) de içeriyorsa, o zaman sadece htaccess bu ekleyin:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /page.php?/$1 [L]

Ancak varsa, page.php dosyalar söylemek / a_folder / another_folder / page.php sağlar ihtiva

. Sonra da htaccess içine koymak gerekir:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /a_folder/another_folder/page.php?/$1 [L]

Ve böylece.

Bu ne yapar, sadece URL'den page.php kaldırır. Senin durumunda böyle:

Instead of: http://mydomain.com/page.php/foo/123/bar/456 You can use: htp://mydomain.com/foo/123/bar/456

Eğlenin.

tüm cevaplar için teşekkür ederim ama ben mod_rewrite kullanırsanız o zaman ben yeni kurallar (ve pek çok) ben yeni bir sayfa oluşturmak her şey yapmak için Haft. Ve onlardan bir sürü var :)

. Htaccess ile benim index.php tüm URL'ler yönlendirmek ve daha sonra wordpress gibi, orada benim URL'yi düzeltmek Belki eğer:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress