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
Apache mod rewrite在live server上不起作用_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache mod rewrite在live server上不起作用

Apache mod rewrite在live server上不起作用,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,我在下面有一个简单的重写规则,它在我的本地机器上运行良好,但当我上传到我的live server时,它不起作用 错误: Options +FollowSymlinks RewriteEngine on RewriteRule ^(.*)\.htm $1.php [NC] RewriteRule jobs/([0-9]+)/(.*)/ jobs.php?id=$1 [NC] RewriteRule testimonial-details/([0-9]+)/(.*)/ testimonial-det

我在下面有一个简单的重写规则,它在我的本地机器上运行良好,但当我上传到我的live server时,它不起作用

错误:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm $1.php [NC]
RewriteRule jobs/([0-9]+)/(.*)/ jobs.php?id=$1 [NC]
RewriteRule testimonial-details/([0-9]+)/(.*)/ testimonial-details.php?id=$1 [NC]
RewriteRule testimonials/([0-9]+)/(.*)/ testimonials.php?id=$1 [NC]
找不到请求的URL /重定向:/jobs.php/1/field-engineer.php/1/field-engineer.php不可用 在此服务器上找到

此外,在尝试查找时遇到404 Not Found错误 使用ErrorDocument来处理请求

.htaccess:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm $1.php [NC]
RewriteRule jobs/([0-9]+)/(.*)/ jobs.php?id=$1 [NC]
RewriteRule testimonial-details/([0-9]+)/(.*)/ testimonial-details.php?id=$1 [NC]
RewriteRule testimonials/([0-9]+)/(.*)/ testimonials.php?id=$1 [NC]

非常感谢您的帮助。

您是否检查了您的重写模块是否已加载? 顺便说一句,您应该在htaccess中检查它:

<IfModule mod_rewrite.c>
// your rewrite stuff here
</IfModule>

//你重写的东西在这里
编辑:

也许这会有帮助。尝试将PT标志设置为第一个重写规则

RewriteRule^(.*)\.htm$1.php[NC,PT]

这将告诉引擎在生成的URL上创建一个干净的第二条路径。因为根据你的规则,有一种奇怪的行为

网址

jobs/1/civil engineer.html
被重写为
jobs/1/civil engineer.php

但是下面的规则

jobs/([0-9]+)/(.*)/
正在等待类似
jobs/1/civil engineer.php/

我做了一些测试,但删除“/”只避免了某些错误,但行为仍然很奇怪。我找到的唯一方法是添加PT标志或更改


RewriteRule jobs/([0-9]+)/(.*)php jobs.php?id=$1

是的,它在live server上工作。而且,最后的重写也在起作用。。。重写规则证明文件/([0-9]+)/(.*)//testicials.php?id=$1[NC]。。。但另外两个没有。感谢您将哪个链接重写为
/redirect:/jobs.php/1/field engineer.php/1/field engineer.php
localhost/jobs/1/civil-engineer.html和代码->$jobs\u url=WEBSITE\u url'jobs/”$行->作业id。“/”$助手->格式化url关键字($row->position)。”。html';我想网站的URL会根据你的网站域名而改变。对不起,我没有线索,规则似乎是正确的。对不起,该网站的URL相当于“http://”$_服务器['HTTP_HOST']./'-它是在my global-config.php上定义的。谢谢