1

I need help with url redirection e.g.

old url http://www.example.com/sub-dir/index.php?id=1 to new url http://www.example.com/sub-dir/1/

can anyone help please I need the .htaccess code file to be in /sub-dir/ folder

Here is the code that I was trying to use:

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

But it didn't work.

Alex K
  • 8,269
  • 9
  • 39
  • 57
  • 1
    You might want to expand out your question a bit more. It doesn't look like you put much work into it. If you aren't willing to put work into explaining and clarifying your question, how can you expect others to put work into answer your question? – Alex K Nov 07 '14 at 05:40
  • O I added the code that I was trying Alex :-) – user3602582 Nov 07 '14 at 05:43
  • got it is working using this code:RewriteRule ^([0-9]+)/$ index.php?id=$1 [NC,L] – user3602582 Nov 07 '14 at 07:41

1 Answers1

0

You can use this rule in /sub-dir/.htaccess:

DirectoryIndex index.php
RewriteEngine On
RewriteBase /sub-dir/

RewriteRule ^([0-9]+)/?$ index.php?id=$1 [QSA,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    thanks for your help I got it working using this code:RewriteRule ^([0-9]+)/$ index.php?id=$1 [NC,L] I only needed to remove / – user3602582 Nov 07 '14 at 07:42