1
votes

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.

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
O I added the code that I was trying Alex :-) - user3602582
got it is working using this code:RewriteRule ^([0-9]+)/$ index.php?id=$1 [NC,L] - user3602582

1 Answers

0
votes

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]