Friendly URLS / URL Rewriting using .htaccess on g

2019-08-02 07:26发布

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?

2条回答
我想做一个坏孩纸
2楼-- · 2019-08-02 07:41

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]
查看更多
Luminary・发光体
3楼-- · 2019-08-02 07:57

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>
查看更多
登录 后发表回答