Subfolders and mod-rewrite

后端 未结 2 1459
不思量自难忘°
不思量自难忘° 2021-01-24 14:53

I need to alter this current re-write rule to accommodate for an admin folder. Here is my current mod-rewrite code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}          


        
相关标签:
2条回答
  • 2021-01-24 15:18

    Add this to your root .htaccess:

    RewriteCond ^admin/
    RewriteRule (whatever rule you need for the admin folder) [L]
    

    Add this right after the RewriteEngine On. The key point here is [L] which tells mod-rewrite to stop executing the rest of the rules if this one matches. If you need more than one rule for the admin folder, just add more RewriteRule statements, but remember to only add the [L] to the last one.

    That should do it.

    0 讨论(0)
  • 2021-01-24 15:30

    Add

    RewriteCond ^admin/
    RewriteRule (your Rule) [L]
    

    before the other condition. That should do the trick.

    Another way would be to include the condition in the rule directly via

    RewriteRule ^admin/(rest_of_regex)$ (regex_stuff) [L]
    
    0 讨论(0)
提交回复
热议问题