Simple .htaccess rewrite to pass 1 parameter

后端 未结 3 1386
独厮守ぢ
独厮守ぢ 2020-12-19 17:43

Can someone please tell me what should my .htaccess file contain to create the following rewrite:

http://www.example.com/success

to call

3条回答
  •  囚心锁ツ
    2020-12-19 18:17

    Heres is one way to do it:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^.*(success)/?$
    RewriteRule .* http://www.mysite.com/index.php?q=%1 [L]
    

    UPDATED

    This modification allows for any word(s) instead of success in the previous version:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^.*/(\w+)$
    RewriteRule .* http://www.mysite.com/index.php?q=%1 [L]
    

提交回复
热议问题