Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess HTACCESS重写在Ubuntu 14、Apache2上不起作用_.htaccess_Ubuntu_Redirect_Apache2_Lamp - Fatal编程技术网

.htaccess HTACCESS重写在Ubuntu 14、Apache2上不起作用

.htaccess HTACCESS重写在Ubuntu 14、Apache2上不起作用,.htaccess,ubuntu,redirect,apache2,lamp,.htaccess,Ubuntu,Redirect,Apache2,Lamp,首先,我不是Linux甚至Apache方面的专家,我习惯于在Windows、WAMP上工作,您只需在图标上单击鼠标右键,然后更改要更改的配置 现在我的灯工作正常,唯一不工作的是HTACCESS重写: Options -MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php?url=$1 [QS

首先,我不是Linux甚至Apache方面的专家,我习惯于在Windows、WAMP上工作,您只需在图标上单击鼠标右键,然后更改要更改的配置

现在我的灯工作正常,唯一不工作的是
HTACCESS
重写:

Options -MultiViews
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
这是一种常见的HTACCESS设置

每次我写URL时:
localhost/mysite/services
都会抛出404错误

你必须知道,我已经尝试了在Stackoverflow和Ubuntu论坛上看到的一切

1) 当我检查mod rewrite是否处于活动状态时,它会说它处于活动状态 2) 我在
“/etc/apache2/sites available”
中创建了一个
“default.conf”
文件,并将其放入:

<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>

选项索引跟随符号链接多视图
允许超越所有
命令允许,拒绝
通融
#如果要查看apache2,请取消对该指令的注释
#转到时的默认起始页(在/apache2默认值中)/
#重定向匹配^/$/apache2默认值/
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>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
1美元^(索引\.php | public | hme | img | editor | tsd | wd | images | edi | js | font | assets | robots\.txt | css | blog)
重写规则^(.*)$index.php/$1[L]

希望这有帮助。

您的htaccess在哪里?在根文件夹中还是在
mysite
文件夹中?还有,您的
index.php
在哪个文件夹中?是的,先生。。。它与index.phpRight位于同一根文件夹中。您有两种解决方案。首先是将这一行
RewriteBase/
添加到
RewriteEngine On
的后面。第二是在规则中的
index.php
之前添加一个前导斜杠:
RewriteRule^(.*)$/index.php?url=$1[QSA,L]
。这两个都是等价的谢谢你@JustinIurman,但它不起作用。。。仍然显示404错误