.htaccess无法正确处理网址

时间:2017-12-14 04:15:36

标签: .htaccess mod-rewrite apache2

我正在获取404 - 找不到页面,而我的.htaccess文件应按照定义重定向URi:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1
    RewriteRule ^profile/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=profile&id=$1
    RewriteRule ^m_profile/([0-9]+)/([A-Za-z0-9-]+)/?$ mobile.php?page=profile&i$
    RewriteRule ^chat/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=chat&id=$1
</IfModule>

例如,以下所有网址都是死链接:

http://www.example.com/meet
http://www.example.com/profile/1/Admin

任何人都知道这是什么问题?

1 个答案:

答案 0 :(得分:0)

尝试.htaccess 301重定向。

RewriteCond %{SCRIPT_FILENAME} [NC]

[NC]指定http主机不区分大小写。

RewriteRule ^chat/([0-9]+)/([A-Za-z0-9-]+)/?$ index.php?page=chat&id=$1 [L,R=301]

[L,R = 301]描述了重写规则的目标 - 这是&#34; final&#34;使用域名。