Search code examples
apacheurl-rewritingmode

Apache mod_rewrite for uri with no extension


I need help with apache url rewrite,I want all urls with no extension to be redirected to index.php?id=query_string.

http://www.abc.com/abc it should go to http://www.abc.com/index.php?id=abc

for links with extensions it should not disturb

Thanks


Solution

  • Not sure this is what you're looking for, but here's my go at it:

    RewriteEngine On
    RewriteRule     ^[!/.]*([A-Za-z]+)/?$       /index.php?id=$1    [NC,L]
    

    If the URL does not contain a '.' character and it contains just letters it puts it in the 'id' request, else it leaves it unchanged

    Hope this helps.