Shorten the URL from example.com/page.php?var=letters to example.com/letters

前端 未结 3 1849

I\'m kinda new to URL Rewriting in .htaccess , and I tried to do it myself following some tutorials. No success though ....

I want to shorten http://www.example.co

相关标签:
3条回答
  • 2021-01-26 12:13

    TRiG's answer should get you up and running however, I would strongly suggest you check out:

    .htaccess tips and tricks

    It is an excellent tutorial which should help you get your head round this stuff, part 2 covers mod_rewrite.

    0 讨论(0)
  • 2021-01-26 12:21
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f # if the requested file does not exist
        RewriteRule ^(.+)$ page.php?var=$1 # rewrite the request
    </IfModule>
    
    0 讨论(0)
  • 2021-01-26 12:26

    A more generic approach, to have all the links you want as domain.tld/person/jon/

    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # rewrites all urls to index.php/url
    RewriteRule .* index.php/$0 [PT]
    
    0 讨论(0)
提交回复
热议问题