首先,我不是 Linux 甚至 Apache 方面的专家,我习惯于在 Windows、WAMP 上工作,您只需点击图标并更改您想要更改的配置。
现在我的 LAMP 工作正常,唯一不工作的是 HTACCESS
改写:
Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
这是一个常见的 HTACCESS 设置。
每次我写网址:
localhost/mysite/services
它会引发 404 错误。你必须知道我已经尝试了我在 Stackoverflow 和 Ubuntu 论坛中看到的所有内容。
1)当我检查mod重写是否处于事件状态时,它说它是
2) 我创建了一个
"default.conf"
文件在 "/etc/apache2/sites-available"
并将其放入:<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
3)在那之后我重新启动了apache2服务
似乎没有任何效果,我很绝望,因为我必须为明天完成这项工作。
编辑 :
这个确切的配置在 Windows-WAMP 和生产服务器(hostgator)上工作......我刚刚将所有应用程序粘贴到我的 Ubuntu 笔记本电脑上,在这里,它不起作用。
最佳答案
我在 Ubuntu 14 中使用 apache2,这对我来说很好。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|hme|img|editor|tsd|wd|images|edi|js|fonts|assets|robots\.txt|css|blog)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
希望这可以帮助。
关于.htaccess - HTACCESS 重写在 Ubuntu 14、Apache2 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25354932/