Apache/Ubuntu块路由
在symfony路由上遇到了一个神秘的问题 我正在切换到symfony with me development安装程序,因为我在使用linux虚拟机运行windows时总是遇到问题 好的,LINUX运行,但我的symfony路由不起作用 谈论这段代码:Apache/Ubuntu块路由,apache,symfony,ubuntu,routing,vhosts,Apache,Symfony,Ubuntu,Routing,Vhosts,在symfony路由上遇到了一个神秘的问题 我正在切换到symfony with me development安装程序,因为我在使用linux虚拟机运行windows时总是遇到问题 好的,LINUX运行,但我的symfony路由不起作用 谈论这段代码: class IndexController extends Controller { /** * @Route("/index", name="index") */ public function index(
class IndexController extends Controller
{
/**
* @Route("/index", name="index")
*/
public function index()
{
return $this->render('index/index.html.twig', [
'controller_name' => 'IndexController',
]);
}
}
在阿帕奇,它说
Not Found
The requested URL /test was not found on this server.
Apache/2.4.27 (Ubuntu) Server at tools.dev Port 80
如果我将路由更改为@route(“/”,name=“index”),一切正常。但除了根以外,任何其他途径都是不可能的。这不是一个符号问题。如果我启动php内部服务器并在浏览器中尝试Url(),它就可以正常工作
Permissions are set to
n00n@ubuntu:/var/www/html/n00n-tools$ ls -la
insgesamt 296
drwxrwxr-x 13 n00n n00n 4096 Jul 7 16:20 .
drwxrwxr-x 3 n00n n00n 4096 Jul 7 16:16 ..
drwxrwxr-x 2 n00n n00n 4096 Jul 7 16:17 assets
drwxrwxr-x 2 n00n n00n 4096 Jul 7 16:17 bin
-rwxrwxr-x 1 n00n n00n 2036 Jul 7 16:22 composer.json
-rwxrwxr-x 1 n00n n00n 208091 Jul 7 16:22 composer.lock
drwxrwxr-x 4 n00n n00n 4096 Jul 7 16:17 config
-rwxrwxr-x 1 n00n n00n 1231 Jul 7 16:17 .env
-rwxrwxr-x 1 n00n n00n 1231 Jul 7 16:17 .env.dist
-rwxrwxr-x 1 n00n n00n 416 Jul 7 16:17 .gitignore
drwxrwxr-x 3 n00n n00n 4096 Jul 7 16:28 .idea
-rwxrwxr-x 1 n00n n00n 302 Jul 7 16:17 package.json
-rwxrwxr-x 1 n00n n00n 1116 Jul 7 16:17 phpunit.xml.dist
drwxrwxr-x 2 n00n n00n 4096 Jul 7 16:17 public
drwxrwxr-x 6 n00n n00n 4096 Jul 7 16:17 src
-rwxrwxr-x 1 n00n n00n 9881 Jul 7 16:22 symfony.lock
drwxrwxr-x 3 n00n n00n 4096 Jul 7 16:19 templates
drwxrwxr-x 2 n00n n00n 4096 Jul 7 16:17 tests
drwxrwxr-x 2 n00n n00n 4096 Jul 7 16:17 translations
drwxrwxr-x 4 n00n n00n 4096 Jul 7 16:17 var
drwxrwxr-x 20 n00n n00n 4096 Jul 7 16:22 vendor
-rwxrwxr-x 1 n00n n00n 852 Jul 7 16:17 webpack.config.js
这是主机的apache配置文件:
<VirtualHost *:80>
ServerName n00n.tools
ServerAlias n00n.tools
DocumentRoot /var/www/html/n00n-tools/public/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/n00n-tools/public/>
DirectoryIndex index.html index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
ServerName n00n.tools
ServerAlias n00n.tools
DocumentRoot/var/www/html/n00n-tools/public/
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
DirectoryIndex.html index.php
允许超越所有
命令允许,拒绝
通融
有什么提示吗
谢谢,,
n00n是否启用了修改重写?此外,我总是将目录块放在VHost之外,但我不确定它是否重要。mod_重写可能是问题所在。是的,它已启用。这是我要检查的第一件事。然后你能粘贴
.htaccess
文件吗?该文件应该重写到你的PHP入口点吗?@TobiasK我从来没有使用过.htaccess文件。我总是通过a2enmod rewrite激活modrewrite。我错了吗?您需要启用mod_rewrite
,a2enmod
就可以了。但您还需要实际使用它将所有内容重写到index.php
。基本示例:RewriteEngine On
#处理前控制器…
RewriteCond%{REQUEST_FILENAME}-d
重写cond%{REQUEST_FILENAME}-f
重写规则^index.php[L]