友好的网址/网址重写在goaddy共享服务器上使用.htaccess


Friendly URLS / URL Rewriting using .htaccess on godaddy shared server

我一直在到处寻找一些代码来与我的 godaddy URL 重写一起使用,但没有运气。

我正在尝试使用带有 .htaccess 的友好 URL 制作我的网站,例如 domain.com/company/buy/items.php?fatherID=23 ==> 到 ==> domain.com/23 我尝试了几乎所有代码,我得到的最好的方法是删除.php

示例代码:

选项 +关注符号链接 - 多视图

打开mod_rewrite

重写引擎打开

重写库/

重写规则 ^/([0-9]+)/?$ 公司/项目.php?父亲ID=$1 [NC,L]

有人对一些简单的代码有任何想法吗?我在 godaddys 共享的 Linux 服务器上。

我尝试使用以下方法重新处理 404 错误代码:错误文档 404/domain.com/home/404error.php但这也没有奏效。

我错过了什么吗?

试试这个,应该是工作

<IfModule mod_rewrite.c>
 Options -MultiViews      
  RewriteEngine on
  RewriteBase /
  RewriteRule ^([0-9]+)$ company/items.php?fatherID=$1 [L]
</IfModule>

Godaddy是一个特例。它肯定会起作用。

 DirectoryIndex index.php
 AddDefaultCharset utf-8
 RewriteEngine on
 Options +FollowSymlinks -MultiViews -Indexes   
 RewriteBase /
 RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]