Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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
Php 修改-另一个简单的我相信_Php_Apache_Mod Rewrite - Fatal编程技术网

Php 修改-另一个简单的我相信

Php 修改-另一个简单的我相信,php,apache,mod-rewrite,Php,Apache,Mod Rewrite,目前正在制作一个php模板/框架。现在我已经按照建议做了,将所有普通文件放在一个PUBLIC文件夹中,其他文件夹中包含库和配置,并将index.php放在PUBLIC文件夹中,但尝试进行修改写入,但什么都不起作用-我使用Coral8服务器(用于测试)并且已经正确地配置了它,但似乎不起作用 以下是我尝试过的: RewriteEngine on RewriteRule ^public/?$ /public/index.php RewriteRule ^public/([^/]+)/?$ /publi

目前正在制作一个php模板/框架。现在我已经按照建议做了,将所有普通文件放在一个PUBLIC文件夹中,其他文件夹中包含库和配置,并将index.php放在PUBLIC文件夹中,但尝试进行修改写入,但什么都不起作用-我使用Coral8服务器(用于测试)并且已经正确地配置了它,但似乎不起作用

以下是我尝试过的:

RewriteEngine on
RewriteRule ^public/?$ /public/index.php
RewriteRule ^public/([^/]+)/?$ /public/index.html
还有这个

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    public/    [L]
    RewriteRule    (.*) public/$1    [L]
 </IfModule>`
<IfModule mod_rewrite.c>
RewriteEngine On

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

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

重新启动发动机
重写规则^$public/[L]
重写规则(.*)public/$1[L]
`
还有这个

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    public/    [L]
    RewriteRule    (.*) public/$1    [L]
 </IfModule>`
<IfModule mod_rewrite.c>
RewriteEngine On

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

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$index.php?url=$1[PT,L]
但似乎都不管用:( 提前谢谢你,但是有人告诉我我做错了什么,这样我就可以从错误中吸取教训,然后如何纠正它


谢谢你这就是你要找的吗

RewriteEngine on
RewriteRule (.*)\.html$ /public/?action=$1&%{QUERY_STRING}$ [L]
RewriteRule ^$ /public [L] 

所以你的URL看起来像
relution.co.uk/about.html

什么意思?你的apache配置文件中是否启用了.htaccess?以上所有这些都会不断出现501或500错误OK你能告诉我你想要的URL和它现在的URL吗?然后我可以看看你的mod_rewrite是否正确。ATM正在运行local服务器,因此index.php的路径将是R://uniserver/www/public.index.php,当直播时,它将是relution.co.uk/public/index.html,或者很抱歉这么模糊,这对我来说是一个非常大的学习曲线,因为我已经习惯了旧的html,这是关于它的,只要它有帮助,这就是index.php,有人告诉我,它会有所不同,因为我使用GET command
如果这是url结果的话看起来就是这样…只是想解释一下..html和.php没有什么区别..这是否考虑到大多数文件都是公开的/很抱歉有这么多问题,但我不喜欢被放在一个盘子上,我想从我在文件中犯的错误中吸取教训紧张不重要。如果您希望友好URL以common.html结尾,那么可以按照我的方式完成。如果您希望它们以php结尾,您可以将
(.*)\.html$
更改为
(.*)\.php$
那么mod_rewrite将在内部将URL重定向到
/public/?action=
。这仅在index.php位于
relution.co.uk/public
中时有效。非常感谢您现在我了解到您没有单独制定重定向规则,因为它已准备就绪,包含在/public/?部分中……谢谢您的帮助:)是的,没错。实际上不需要包含index.php,因为它是索引文件。它对你有用吗?是的,在测试服务器上工作过,只是在live服务器上尝试过,当我尝试在relution.co.uk上获取站点时,得到了403错误,但当我转到relution.co.uk/index.html时,效果非常好。有办法解决这个问题吗?
RewriteEngine on
RewriteRule ^$ /public/index.html [L]
//made addition on index.html and put it first so that it is the first rule to be applied and then makes the condition for the next rule to apply 
RewriteRule (.*)\.html$ /public/?action=$1&%{QUERY_STRING}$ [L]