のドキュメントルートを変更するには、既存のApacheの設定を変更する方法:だから私は非常にApacheで経験していないが、私は私のテストボックスの数ヶ月のために以下の設定を実行するために管理している新しいアプリケーション
[email protected]:/etc/apache2/sites-enabled$ vim 000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
基本的には、いつでも私は/ var/www/htmlの下に新しいフォルダを作成すると、それは私のブラウザで利用できるようになります。
/var/www/htmlと設定/ testrestapp/SRC /公共/インデックス:私は次の構造を持つ、新しいアプリケーションを作成しました
: は、しかし、今、私は次の操作を行うために試してみたいです
.PHPそれは動作しますが、私はに移動する必要があります。
http://localhost/testrestapp/src/public/index.php/hello/sometestname
してから、アプリケーション・リターンS「sometestname」
しかし、私はこのようにナビゲートすることができるようにApacheを設定する方法を知りたい:
http://localhost/testrestapp/hello/sometestname
と同じ結果を得ます。
誰かが私を正しい方向に向けることができますか? Googleにこれにどのような用語を使用するかは不明です。
ありがとうございました。
EDIT 1
私は次のようでした。その後、
[email protected]:/etc/apache2/sites-enabled$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
未遂の再起動:
[email protected]:/etc/apache2/sites-enabled$ service apache2 restart
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
Apr 19 10:14:39 mydev apache2[9010]: * The apache2 configtest failed.
Apr 19 10:14:39 mydev apache2[9010]: Output of config test was:
Apr 19 10:14:39 mydev apache2[9010]: AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/000-default.conf:
Apr 19 10:14:39 mydev apache2[9010]: RewriteBase: only valid in per-directory config files
Apr 19 10:14:39 mydev apache2[9010]: Action 'configtest' failed.
Apr 19 10:14:39 mydev apache2[9010]: The Apache error log may have more information.
Apr 19 10:14:39 mydev systemd[1]: apache2.service: Control process exited, code=exited status=1
Apr 19 10:14:39 mydev systemd[1]: Failed to start LSB: Apache2 web server.
Apr 19 10:14:39 mydev systemd[1]: apache2.service: Unit entered failed state.
Apr 19 10:14:39 mydev systemd[1]: apache2.service: Failed with result 'exit-code'.
は、ここに私の/ etc/apache2の/ 000- /サイト対応のものですdefault.confファイルは次のようになります。
11 ServerAdmin [email protected]
12 DocumentRoot /var/www/html
13 RewriteEngine on
14 RewriteBase /testrestapp/
15 RewriteRule ^src/public/index.php/hello$ hello/ [R]
EDIT 2:
私の000-は、default.confファイルは次のようになります。
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory "/var/www/html/testrestapp/">
RewriteEngine on
RewriteBase /testrestapp/
RewriteRule ^src/public/index.php/hello$ hello/ [R]
</Directory>
Apacheが正常に再起動:
[email protected]:/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart
[ ok ] Restarting apache2 (via systemctl): apache2.service.
しかし、私はhttp://localhost/testrestapp/hello/jojoに移動したときに私が手を404エラー。
これは私がのaccess.logに見えるものです:
127.0.0.1 - - [19/4月/ 2016:13:50:04 -0400]「GET/testrestapp /ハロー/ジョジョHTTP/1.1 Mozilla/5.0(X11; Linux x86_64)AppleWebKit/537.36(GeckoのようなKHTML)Chrome/49.0.2623.110 Safari/537.36 "
ウェブマスター@ localhostのがちょうど役に立たない私に知らせてくれてありがとう@tripleee – tripleee
を私だけ左にすべてのデフォルトが最初に持って申し訳ありません – Happydevdays
@Happydevdaysをセットアップしたときからあなたが誤解を招いてしまいました。あなたのEDITと時間のスピードアップは、あなたが私の答えで見ることができるように不必要でした。 – menssana