Reputation: 4601
In my .htaccess file i have the following re-write rule
RewriteRule ^([a-z]*)$ work.php?album=$1 [L]
I am reading all directories in root directoy and creating links like
code in PHP
$dir=glob('images/works/*');
$dir_listing=array();
foreach($dir as $list)
{
if(is_dir($list))
$dir_listing[]= (basename($list));
}
foreach($dir_listing as $folders )
echo"<a href='$folders' ><img src='Default-thumbnail-folder.jpg' /> </a>";
the problem is i have three folders under works directory {alb,ban,bas}
the first and last {alb and bas} work properly for my redirect rule URL{siteName/works/bas}
but the second {ban} creates a URL like {siteName/works/ban/} Notice the extra "/" is creating the problem, it seems for some folder names it is creating the problem, so please help me in creating a proper redirect rule
i want a link like
<a href="alb" >About</a> // to redirect to work.php?content=about
I also notice that if URL in browser is like work/alb/ CSS is not applied i tried
<link href="sample.css" rel="stylesheet" type="text/css" />
and
<link href="css/sample.css" rel="stylesheet" type="text/css" />
it does not work for URL like {works/about/} it works for {works/about}
Upvotes: 0
Views: 82
Reputation: 169
to avoid rewriting css URI's use these rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
as for your other problem you can use a trim on the result url to make sure you never have a "/" at the end
trim($url,'/');
Upvotes: 1
Reputation: 15778
Easy!
Try to change your rewriterule to:
RewriteRule ^([a-z]*)/?$ work.php?album=$1 [L]
So that the "/
" at the end may or may not be present, in both cases it's ok.
Upvotes: 1