Htacces url 重写不起作用



我一直在试图弄清楚urlrewrite。我认为我仍然没有真正理解它。所以我试了这个:

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

而且我显然没有工作,我的页面甚至无法正常加载

当我使用普通网址时:

forum/?catagory=test

这效果很好,会向我展示一切。我不明白为什么网址重写不起作用!甚至尝试了发电机和其他一些东西。它行不通

关闭MultiViews选项:

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

选项 MultiViews 由在 mod_rewrite 之前运行的Apache's content negotiation module使用,并使 Apache 服务器匹配文件的扩展名。所以/file可以在 URL 中,但它会/file.php服务。

首先,你打开了重写引擎吗?其次,是否启用了重写模块?做一个phpinfo();来检查它和这个答案。

这边:

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

此页面可以帮助您: 初学者的 URL 重写

最新更新