Search code examples
.htaccesshttp-redirectmod-rewriteurl-rewritingfriendly-url

How i can redirect several url with htaccess file?


I am currently developing a dashboard for my site but I have a problem with the configuration of my .htaccess file. I will explain the problem: I'm doing a redirect from

RewriteRule ^dashboard/(.*)$ guild.php?guild_id=$1

(.*) = Server ID. But I would like to have this too:

RewriteRule ^dashboard/(.*)/features$ features.php?guild_id=$1

Except that it redirects me to the first file (guild.php and not features.php), I hope to have explained the problem well and that you could help me :) Thanks


Solution

  • With your attempted Rules, please try following htaccess rules. Make sure you clear your browser cache before testing your URLs.

    RewriteEngine ON
    ##Rules for uri which has feature in uri.
    RewriteRule ^dashboard/([^/]*)/features/?$ features.php?guild_id=$1 [NC,L]
    ##Existing rule from OP, fixed NC,L flags in rules too.
    RewriteRule ^dashboard/(.*)/?$ guild.php?guild_id=$1 [NC,L]