在 Godaddy 共享服务器上使用 .htaccess 进行友好 URLS/URL 重写 [英] Friendly URLS / URL Rewriting using .htaccess on godaddy shared server
问题描述
我一直在四处寻找一些代码来处理我的godaddy URL Rewriting,但没有运气.
I have been looking all over the place to find some code to work with my godaddy URL Rewriting, but no luck.
我正在尝试使用带有 .htaccess 的友好 URL 来创建我的网站,例如domain.com/company/buy/items.php?fatherID=23 ==> into ==> domain.com/23 我尝试了几乎所有的代码,我得到的最好的方法是删除 .php
I am trying to make my website with Friendly URLS with .htaccess e.g. domain.com/company/buy/items.php?fatherID=23 ==> into ==> domain.com/23 I tried almost all codes and the best i got to is removing the .php
示例代码:
选项 +FollowSymLinks -MultiViews
Options +FollowSymLinks -MultiViews
开启 mod_rewrite
Turn mod_rewrite on
重写引擎开启
RewriteBase/
RewriteBase /
RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]
RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]
有人对一些简单的代码有任何想法吗?我在godaddys共享Linux服务器上.
Does anyone have any idea with some simple code? I am on godaddys shared Linux server.
我尝试使用以下方法减少 404 错误代码:ErrorDocument 404/domain.com/home/404error.php但这也不起作用.
I tried to redurect 404 error codes with: ErrorDocument 404 /domain.com/home/404error.php but this also did not work.
有什么我遗漏的吗?
推荐答案
试试这个,应该可以了
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^([0-9]+)$ company/items.php?fatherID=$1 [L]
</IfModule>
这篇关于在 Godaddy 共享服务器上使用 .htaccess 进行友好 URLS/URL 重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!