im trying to write a script , that can rewrites urls in slug way such as this :
http://www.mysite.com/mystorytitle/
and i did this in my codes :
RewriteRule ^(.*)\/$ app=News&file=article&title=$1 [L]
and in my php codes, i created a slug out of story’s title as :
$slug_title = mysql_real_escape_string($mtitle);
$show= "<a href=\"$slug_title/\">$mtitle</a>";
now everything is fine unless when i click on slugged link , it goes to the page but without any style and javascripts and images.
im sure that the problem is because of path for css files and … which is been changed a level
as i’m in this path :
http://www.mysite.com/ایمیل/
so if the page requiring css file as this :
<link rel="StyleSheet" href="includes/NAV.css" type="text/css" />
one level changed and to do this worked , i should come back a level as :
<link rel="StyleSheet" href="../includes/NAV.css" type="text/css" />
i guess , this is concidered as a folder not a rewrited path
but im sure there should be another way to make this script work without changing all paths
thanks in advance
You should prepend the base URL (most of the time forward slash, but not always).
You can get it as follows (general expression that will work even if your site resides in a directory):
And then you’ll write:
Another possibility is to use the base tag in head:
This has the advantage of changing only one line in your code.
You can go furthur and make utility method to do this: