简体   繁体   English

在ubuntu 13.10上从XAMPP迁移到LAMP后,htaccess无效(在apache linux server中启用htaccess)

[英]htaccess is not working after moving from XAMPP to LAMP on ubuntu 13.10 (Enable htaccess in apache linux server)

My CodeIgniter project is running successfully on my XAMPP system with the url, 我的CodeIgniter项目在我的XAMPP系统上使用url成功运行,

http://localhost/newsfeeds/users/allCategories/

When I move this project to another system has LAMP server on Ubuntu 13.10. 当我将这个项目移动到另一个系统时,在Ubuntu 13.10上有LAMP服务器。 To run the same page I need the url, 要运行同一页面,我需要网址,

http://localhost/newsfeeds/index.php/users/allCategories/

I need the index.php file otherwise it shows a page not fount error. 我需要index.php文件,否则它显示一个页面而不是fount错误。

My htaccess file is, 我的htaccess文件是,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

How can I run the same project without index.php on both WAMPP and XAMP server ? 如何在WAMPP和XAMP服务器上运行没有index.php的同一个项目?

I found the solution for this issue. 我找到了解决这个问题的方法。

In my server the mode rewrite is already on. 在我的服务器中,模式重写已经开启。 But some default values need to be change on /etc/apache2/apache2.conf file. 但是/etc/apache2/apache2.conf文件需要更改一些默认值。 Following are my changes, 以下是我的更改,

First, find 首先,找到

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

And change AllowOverride None to All and save. 并将AllowOverride None更改为All并保存。

Then enable mode rewrite using the command(In this case already enabeled), 然后使用命令启用模式重写(在这种情况下已经启用),

$ sudo a2enmod rewrite

Then restart the server, 然后重启服务器,

$ sudo /etc/init.d/apache2 restart

Run the project. 运行该项目。 Works fine. 工作良好。

Try this: 试试这个:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM