cowboysaif cowboysaif - 3 months ago 10
PHP Question

What should be the .htaccess rule for following condition?

I have following links :

http://www.example.com/pdf/this-is-a-link.html

which should convert to :

http://www.example.com/index.php?query=this-is-a-link&type=pdf

Also, .css, .js etc files needs to avoid this rule. My .htaccess file so far is this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)?$ $2/$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).html$ index.php?query=$2&type=$1&link=seo [L]

</IfModule>


Problem is, now we have an admin panel. The css and js files are falling into into the
^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/(.*)?$ $2/$3
rule.
Example of such link: http://www.example.com/admin/css/bbpress.css

How can i modify the rule so that "if it NOT contains the word admin..." ?

Answer

Add a condition before first rule:

RewriteCond %{REQUEST_URI} !^admin
Comments