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...

Link to comment
Share on other sites

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]

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.