How to create clean url using .htaccess

前端 未结 3 867
栀梦
栀梦 2020-12-01 23:05

This is my .htaaccess code.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/$ movie.php?name=$1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example\\.in$
Rew         


        
3条回答
  •  有刺的猬
    2020-12-01 23:34

    If you're want to have clean URLs, then you have to use clean URLs in your html code, e.g. use

    Titanic
    

    Your rewrite rules will take that doesn't-really-exist-on-the-server address (you don't really have a /movie directory that contains a titanic file, after all), and translates it in to the actual

    /movie.php?name=titanic
    

    The user would never see this url, however, because the rewrite would take place purely within Apache. As long as the HTML you send to the user contains only "clean" urls, they'll never see the query strings.

提交回复
热议问题