Jump to content

htaccess RewriteRule and admin folder - HELP!


ts2000abc

Recommended Posts

my rewite in htaccess is now:

RewriteRule ^([^/\.]+)(/)?$  index.php?page=$1 [QSA,L]

 

works fine for pages; but how can i get my admin folder to work with that rewriterule? (or other rewriterule)

because now that line just takes "/admin" and uses it as value for $page...

I'll take the liberty of rephrasing your question for you - comment if my assumptions are wrong

Q) How can I exclude the folder /admin from the rewrite rule below?

A) Add a RewriteCond condition to prefix the rule as follows...

 

#If the request URI does not (!), begin with (^), /admin (and nothing after ($)) - compare ignoring case - then apply the rule after

 

RewriteCond %{REQUEST_URI} !^/admin$ [nc]
RewriteRule ^([^/\.]+)(/)?$  index.php?page=$1 [QSA,L]

 

Not had time to test it and problems you may encounter are automatic rewrites of "admin/blah/blah.htm" to "/admin/blah/blah.htm" during the rewrite process by Apache. You can make the / prefix optional if you run into probs. Again not tested. Give it a try.

 

RewriteCond %{REQUEST_URI} !^(/)?admin$ [nc]
RewriteRule ^([^/\.]+)(/)?$  index.php?page=$1 [QSA,L]

 

 

thanx,

that 'RewriteCond' line didn't really do anything... dont know why

 

i used these lines and got it working little bit better:

RewriteBase /
RewriteRule ^admin?$ admin [R,L]
RewriteRule ^([^/\.]+)(/)?$  index.php?page=$1 [QSA,L]

 

now it's working ok; only thing is that when I type the admin address "mysite.com/admin", browser goest to "mysite.com//admin" (extra / in url)

it's still working but just looks bit funny.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.