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

倖福魔咒の 提交于 2019-12-11 06:28:43

问题


I have been looking all over the place to find some code to work with my godaddy URL Rewriting, but no luck.

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

Sample Code:

Options +FollowSymLinks -MultiViews

Turn mod_rewrite on

RewriteEngine On

RewriteBase /

RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]

Does anyone have any idea with some simple code? I am on godaddys shared Linux server.

I tried to redurect 404 error codes with: ErrorDocument 404 /domain.com/home/404error.php but this also did not work.

Is there something I am missing?


回答1:


Try this , it should be work

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



回答2:


Godaddy is a special case. It will work surely.

 DirectoryIndex index.php
 AddDefaultCharset utf-8

 RewriteEngine on
 Options +FollowSymlinks -MultiViews -Indexes   

 RewriteBase /
 RewriteRule ^/([0-9]+)/?$ company/items.php?fatherID=$1 [NC,L]


来源:https://stackoverflow.com/questions/19994375/friendly-urls-url-rewriting-using-htaccess-on-godaddy-shared-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!