我觉得我已经做好了一切:
josiah@BOX-OF-DOOOM:~$ sudo apache2ctl start apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName josiah@BOX-OF-DOOOM:~$ sudo a2enmod rewrite Module rewrite already enabled josiah@BOX-OF-DOOOM:~$ sudo apache2ctl restart apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName josiah@BOX-OF-DOOOM:~$
然后在我的.htaccess(这是CodeIgniter):
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> <IfModule !mod_rewrite.c> # If we don't have mod_rewrite installed, all 404's # can be sent to index.php, and everything works as normal. # Submitted by: ElliotHaughin ErrorDocument 404 /index.php </IfModule> <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Expires "Thu, 15 Apr 2011 20:00:00 GMT" </FilesMatch>
然而,导航到没有明确input“index.php”的东西无法加载。 有任何想法吗?
这应该采取任何url发送(/无论/的/url/是)到Apache和redirect到index.php /无论/ /url/是。 如果我inputindex.php /无论/的/ url /是,那么它的作品很好,但如果我删除index.php,它失败。
编辑:
此外,mod_rewrite似乎并没有被启用,即使a2enmod说,这是(如我粘贴上面)
josiah@BOX-OF-DOOOM:~$ sudo apache2ctl -l [sudo] password for josiah: Compiled in modules: core.c mod_log_config.c mod_logio.c prefork.c http_core.c mod_so.c
在您的VirtualHostconfiguration,或在您的目录块做一些事情:
<Directory /path/to/webroot/> AllowOverride all </Directory>
a2enmod加载模块,那些不是编译成apache,而是dynamic链接的。
如果你把一些.htaccess文件放到你的服务器上,并且不能按预期工作,也许你正在尝试安装一个Drupal站点或设置Zend Framework,按照这个步骤。
find你的站点的虚拟主机文件,或编辑/ etc / apache2 / sites-enabled /
添加以下行:
<Directory /var/www/mysite/> AllowOverride all </Directory>
在这个块之后:
<Directory /> Options FollowSymLinks AllowOverride None </Directory>
重新加载服务器
sudo /etc/init.d/apache2 reload
这应该在每次修改后完成。
如果您尝试查看您的网站时遇到500类错误,请不要惊慌!
出现这种情况的原因是由于安全原因,重写模块默认没有启用。
在放置此行的文件中,在/ etc / apache2 / mods-enabled中创build一个名为rewrite.conf的新文件
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
重新加载一次服务器。