ฉันกำลังพยายามให้ Symfony1.4 และ Symfony2 ทำงานบนโฮสต์เดียวกันใน Apache (2.2.22) - ฉันคิดว่าปัญหาคือทั้งคู่ใช้ mod_rewrite เพื่อส่งคำขอโดยตรงไปยังตัวควบคุม/สคริปต์ php นี่คือการกำหนดค่าของฉัน
httpd.conf
# Symfony 1.4
<VirtualHost *:80>
DocumentRoot "d:/wamp/www/wlnew/web"
DirectoryIndex index.php
<Directory "d:/wamp/www/wlnew/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf d:/wamp/www/wlnew/lib/vendor/symfony/data/web/sf
<Directory "d:/wamp/www/wlnew/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
# Symfony 2
Alias /another "d:/wamp/www/another/web/"
<Directory "d:/wamp/www/another/web">
Options Indexes FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
จากนั้น Symfony แต่ละเวอร์ชันจะมี .htaccess
ซึ่งใช้ในการเขียนคำขอใหม่
ซิมโฟนี 1 .htaccess
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
ซิมโฟนี 2 .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
ฉันต้องการให้สามารถใช้ localhost/
เพื่อเปลี่ยนเส้นทางไปยังตัวควบคุมด้านหน้า Symfony 1 index.php
แต่เมื่อฉันใช้ localhost/another
คำขอทั้งหมดควรส่งต่อไปยังตัวควบคุมด้านหน้า symfony2 app.php
แต่ไม่ได้เป็นเช่นนั้น - พวกเขาจะถูกส่งต่อไปยังตัวควบคุมด้านหน้า symfony1 (index.php
) ถ้าฉันใช้ชื่อไฟล์ของคอนโทรลเลอร์สำหรับ Symfony2 มันจะใช้งานได้เช่น localhost/another/app.php
ฉันจะรับ apache เพื่อส่งต่อคำขอไปยังคอนโทรลเลอร์ Symfony2 ได้อย่างไรเมื่อฉันใช้นามแฝง /another
อัปเดต
ฉันเปิดใช้งานการบันทึกการบันทึกการเขียนซ้ำ ... นี่คือสิ่งที่ฉันได้รับ:
[perdir D:/wamp/www/another/web/] strip per-dir prefix: D:/wamp/www/another/web/ ->
[perdir D:/wamp/www/another/web/] applying pattern '^(.*)$' to uri ''
[perdir D:/wamp/www/another/web/] RewriteCond: input='D:/wamp/www/another/web/' pattern='!-f' => matched
[perdir D:/wamp/www/another/web/] rewrite '' -> 'app.php'
[perdir D:/wamp/www/another/web/] add per-dir prefix: app.php -> D:/wamp/www/another/web/app.php
[perdir D:/wamp/www/another/web/] internal redirect with D:/wamp/www/another/web/app.php [INTERNAL REDIRECT]
[perdir D:/wamp/www/wlnew/web/] add path info postfix: D:/wamp/www/wlnew/web/wamp -> D:/wamp/www/wlnew/web/wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/wamp/www/another/web/app.php -> wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^$' to uri 'wamp/www/another/web/app.php'
[perdir D:/wamp/www/wlnew/web/] add path info postfix: D:/wamp/www/wlnew/web/wamp -> D:/wamp/www/wlnew/web/wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/wamp/www/another/web/app.php -> wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^([^.]+)$' to uri 'wamp/www/another/web/app.php'
[perdir D:/wamp/www/wlnew/web/] add path info postfix: D:/wamp/www/wlnew/web/wamp -> D:/wamp/www/wlnew/web/wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/wamp/www/another/web/app.php -> wamp/www/another/web/app.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^(.*)$' to uri 'wamp/www/another/web/app.php'
[perdir D:/wamp/www/wlnew/web/] RewriteCond: input='D:/wamp/www/wlnew/web/wamp' pattern='!-f' => matched
[perdir D:/wamp/www/wlnew/web/] rewrite 'wamp/www/another/web/app.php' -> 'index.php'
[perdir D:/wamp/www/wlnew/web/] add per-dir prefix: index.php -> D:/wamp/www/wlnew/web/index.php
[perdir D:/wamp/www/wlnew/web/] strip document_root prefix: D:/wamp/www/wlnew/web/index.php -> /index.php
[perdir D:/wamp/www/wlnew/web/] internal redirect with /index.php [INTERNAL REDIRECT]
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/index.php -> index.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^$' to uri 'index.php'
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/index.php -> index.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^([^.]+)$' to uri 'index.php'
[perdir D:/wamp/www/wlnew/web/] strip per-dir prefix: D:/wamp/www/wlnew/web/index.php -> index.php
[perdir D:/wamp/www/wlnew/web/] applying pattern '^(.*)$' to uri 'index.php'
[perdir D:/wamp/www/wlnew/web/] RewriteCond: input='D:/wamp/www/wlnew/web/index.php' pattern='!-f' => not-matched
[perdir D:/wamp/www/wlnew/web/] pass through D:/wamp/www/wlnew/web/index.php
ดูเหมือนว่า .htaccess
สำหรับ Symfony2 (/another
) กำลังถูกอ่านและเปลี่ยนเส้นทางไปที่ app.php
แต่จากนั้นอ่าน .htaccess
อื่น ๆ แล้วเปลี่ยนเส้นทางไปที่ index.php
... ฉันจะทำให้การเขียนซ้ำหยุดที่ app.php
ได้อย่างไร
localhost/another
และlocalhost/another/
? - person cheesemacfly   schedule 22.01.2013.htaccess
- ไม่พบไฟล์ดังนั้นจึงเปลี่ยนเส้นทางไปที่index.php
ด้วยเหตุผลบางประการที่นามแฝงดูเหมือนจะถูกเพิกเฉย - person Manse   schedule 22.01.2013Alias /another "d:/wamp/www/another/web/"
ของคุณมีเครื่องหมายสแลชต่อท้ายสำหรับไดเร็กทอรี ในขณะที่การประกาศคำสั่ง<Directory "d:/wamp/www/another/web">
ของคุณไม่มี แต่อันสำหรับ 1.4 ก็ดูดีนะ อาจจะ? :) - person Nandeep Mali   schedule 29.01.2013.htaccess
หลายไฟล์ - ฉันได้รวมบันทึกแล้ว - person Manse   schedule 29.01.2013RewriteCond %{REQUEST_URI} !=/app.php
ไม่ได้สร้างความแตกต่างเลย ฉันเปลี่ยนเป็นRewriteCond %{REQUEST_URI} !=D:/wamp/www/wlnew/web/wamp
สิ่งเดียวกัน .. - person Manse   schedule 29.01.2013