mod rewrite - htaccess mod_rewrite with trailing slashes issue -


i wondering if help? i've got set of mod_rewrite rules , work except if put trailing slash @ end of url goes crazy. still show's page (sometimes) except of css, js, etc not included because path messes when there's trailing slash. way solve put base tag avoid brings it's own set of issues. there wrong htaccess? need ignore trailing slashes.

options +followsymlinks rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^resetpassword/([^/.]+)/?$ resetpassword.php?resetcode=$1 [l] rewriterule ^activate/([^/.]+)/?$ activateaccount.php?actcode=$1 [l] rewriterule ^dashboard/?$ dashboard.php [nc,l] rewriterule ^login/?$ login.php [nc,l] rewriterule ^register/?$ register.php [nc,l] rewriterule ^messages/inbox/??$ messagesinbox.php [nc,l] rewriterule ^messages/archive/??$ messagesarchive.php [nc,l] rewriterule ^messages/??$ messagesinbox.php [nc,l] 

there's not fix because you'll switching "directory" levels in case (like in messages/inbox).

the common solution either use absolute path reference css, images etc.:

<link rel="stylesheet" href="/css/styles.css"> 

or have php variable containing web root:

<link rel="stylesheet" href="<? echo $webroot; ?>/css/styles.css"> 

both these approaches vastly better using base tag, or doing .htaccess-based redirection shenanigans.


Comments