-->

Friendly URLS / URL Rewriting using .htaccess on g

2019-08-02 07:24发布

问题:

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]