ローカル マシンに XAMPP をセットアップしました。MVC のセットアップを開始しましたが、$_GET がローカル ディレクトリ構造をドライブ文字までずっと返していることに気付きました。しかし、URL構造を返したいです。
私は可能な限りの関連情報を提供しようとしました。
環境
- Windows 7 プロフェッショナル SP1 64 ビット
- XAMPP 1.8.1
ホスト[C:\Windows\System32\drivers\etc\hosts]
127.0.0.1 www.getspark.com
httpd.conf [E:\xampp\apache\conf\httpd.conf]
DocumentRoot "E:/xampp/htdocs/home"
<VirtualHost *:80>
DocumentRoot /xampp/htdocs/home
ServerName getspark
</VirtualHost>
<Directory "E:/xampp/htdocs/home/private">
Order deny,allow
Deny from all
</Directory>
<Directory />
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ /index.php?url=$1 [L,QSA]
</Directory>
Web ディレクトリ構造[E:\xampp\htdocs\home]
home
index.php
private
controllers
public
graphics
HTML5_Logo_512.png
ホームページ[E:\xampp\htdocs\home\index.php | http://www.getspark.com/]
<?php
$url = $_GET['url'];
echo $url . '<br />';
?>
<img src="/public/graphics/HTML5_Logo_512.png" />
次の URL を使用する場合:
http://www.getspark.com/foobar
私はこの出力を得ます:
E:/xampp/htdocs/home/foobar
画像も同様です。
しかし、私はこの出力が欲しい:
foobar
すべての相対 (および絶対) 参照は正しく機能します (画像、php ファイル、js ファイルなど)。