ts2000abc Posted February 2, 2008 Share Posted February 2, 2008 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 https://forums.phpfreaks.com/topic/89047-htaccess-rewriterule-and-admin-folder-help/ Share on other sites More sharing options...
madmax Posted February 2, 2008 Share Posted February 2, 2008 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 https://forums.phpfreaks.com/topic/89047-htaccess-rewriterule-and-admin-folder-help/#findComment-456063 Share on other sites More sharing options...
ts2000abc Posted February 2, 2008 Author Share Posted February 2, 2008 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 https://forums.phpfreaks.com/topic/89047-htaccess-rewriterule-and-admin-folder-help/#findComment-456118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.