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
Html Htacces url重写不起作用_Html_.htaccess_Url_Url Rewriting - Fatal编程技术网

Html Htacces url重写不起作用

Html Htacces url重写不起作用,html,.htaccess,url,url-rewriting,Html,.htaccess,Url,Url Rewriting,我一直在想重写的方法。我想我还没有真正明白。 所以我试了一下: Options -Indexes +ExecCGI AddHandler cgi-script .cgi .pl php_flag display_startup_errors on php_flag display_errors on php_flag html_errors on php_flag log_errors on Options -MultiViews RewriteEngine On RewriteBase /

我一直在想重写的方法。我想我还没有真正明白。 所以我试了一下:

Options -Indexes +ExecCGI
AddHandler cgi-script .cgi .pl
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on
php_flag  log_errors on
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^home/? index.php
RewriteRule ^forum/?$ forum.php [L,NC]
RewriteRule ^forum/([a-z0-9-]+)/?$ forum.php?catagory=$1 [L,QSA,NC]
RewriteRule ^login/? loginpage.php
RewriteRule ^register/? registerpage.php
RewriteRule ^servers/? servers.php
RewriteRule ^profile/? profile.php
RewriteRule ^profile/([A-Za-z0-9-]+)/?$   profile?user=$1
RewriteRule ^members/? memebers.php
我显然没有工作,我的页面甚至无法正常加载

当我使用普通url时:

forum/?catagory=test

这个效果很好,可以让我看到一切。我不明白为什么url重写不起作用!甚至试过发电机和其他东西。它不工作了首先,你把引擎打开了吗? 第二,是否启用了重写模块?做一个
phpinfo()
来检查它并查看此

这样:

RewriteEngine On
RewriteBase /
RewriteRule ^forum/?$ forum.php
RewriteRule ^forum/([A-Za-z0-9-]+)/?$ forum.php?catagory=$1 [L]

此页面可以帮助您:

关闭
多视图
选项:

Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^forum/?$ forum.php [L,NC]
RewriteRule ^forum/([a-z0-9-]+)/?$ forum.php?catagory=$1 [L,QSA,NC]

选项
MultiViews
Apache的内容协商模块使用,该模块在
mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。所以
/file
可以在URL中,但它将服务于
/file.php

您是否在
上有
重写引擎
重写库/
第一件事,是的。我现在添加的第二件事,但没有帮助。如果你去
/forum/test
,会发生什么?您收到404错误,或者forum.php加载时没有类别?@Nytrix:您在
/forum/
文件夹中也有.htaccess吗?@anubhava没有这样的文件夹。这是对forum.phpI的重写,让引擎打开并启用它:正如所说的那样“/forum/?catagory=test”起作用。我尝试了你的代码,但仍然无法工作。你的日志中是否有可以提供帮助的错误输出?是的,我加载的所有内容都会得到一个无法加载的错误:“加载资源失败:服务器响应状态为404(未找到)”,我在问题中添加了我的整个.htacces。test.com/forum/test页面不起作用。我明白了。我应该得到这样的结果:好吧,看起来问题是并没有得到你们的css/js。这是因为您使用了css/js/images的相对链接。您可以尝试将其添加到页面的HTML标题中:
,这样每个相对URL都将从该URL而不是当前页面的URL解析。我将尝试!唯一奇怪的是,如果我正常输入:“test.com/forum/?catagory=test”就行了。它有点不起作用,你是对的,它从错误的东西获取css/js/图片:。但是你的回答没有起作用。。