![](/img/trans.png)
[英]Codeigniter + htaccess for index.php + subdomain not working
[英]codeigniter .htaccess in amazon ec2 removal of index.php not working
codeigniter .htaccess
在亞馬遜ec2中刪除index.php不能正常工作
碼
RewriteEngine on
RewriteBase http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
配置文件
$config['base_url'] = 'http://ec2-xx-xxx-xx-xx.us-west-2.compute.amazonaws.com/';
您可以像這樣更改.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
並在/etc/httpd/conf/httpd.conf上更改“ AllowOverride None ”的值(如果使用AMI Linux)
進入“ AllowOverride All ”
之后用這樣的命令重新啟動你的apache:
sudo service httpd restart
它的工作和我的aws ec2測試。
(if you use ubuntu)
Activate the mod_rewrite module with
sudo a2enmod rewrite
and restart the apache
sudo service apache2 restart
To use mod_rewrite from within .htaccess files (which is a very common use case), edit the default VirtualHost with
sudo nano /etc/apache2/sites-available/000-default.conf
Search for “DocumentRoot /var/www/html” and add the following lines directly below:
<Directory "/var/www/html">
AllowOverride All
</Directory>
Save and exit the nano editor via CTRL-X, “y” and ENTER.
Restart the server again:
sudo service apache2 restart
Justudin是對的!
您也可以將“ AllowOverride All ”規則僅用於您的項目; 在/etc/httpd/conf/httpd.conf中寫這樣的東西:
<Directory "/var/www/your_website">
AllowOverride All
</Directory>
只有您可以對所有已部署的應用程序使用“AllowOverride All”規則; 在/etc/httpd/conf/httpd.conf中編寫:
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.