Forum Moderators: phranque
[START of HTACCESS]
RewriteEngine On
# Prevent looping for files with an extension
RewriteCond %{REQUEST_URI}!^/.+\.[a-z5]{2,4}$
# dept redirect
RewriteRule ^([a-zA-Z0-9]+)$ dept.php?dn=$1 [L]
# employee redirect
RewriteRule ^([a-zA-Z0-9]+)-([a-zA-Z0-9]+)$ emp.php?dn=$1&en=$2 [L]
[END of HTACCESS]
Now the above works fine. URLs such as:
[mydomain.com...]
[mydomain.com...]
all redirect fine. As does
[mydomain.com...]
Lovely. However, a URL such as
[mydomain.com...] - redirects to the PHP file no problem, but the CSS file is not included. It appears that the extra "/" on the end has somehow mangled the path to the CSS .... the CSS is included using '<style type="text/css" media="screen">@import url(css/main.css);</style>'
I have tried:
RewriteRule ^([a-zA-Z0-9]+)$ dept.php?dn=$1 [L]
but makes no difference.
Once I get this working, I'd like to move to separators using "/" as opposed to "-" as used currently.
Any suggestions anyone as to how to deal with this folder issue?
Thanks,
S
I suggest using server-relative links:
<style type="text/css" media="screen">@import url[b](/c[/b]ss/main.css);</style>'
Jim
So what I now have is .....
RewriteRule ^([a-zA-Z0-9]+)/$ dept.php?dname=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/css/screen.css$ ./css/main.css [L]
RewriteRule ^([a-zA-Z0-9]+)/scripts/js.js$ ./scripts/js.js [L]
However - what I'd like to do is *force* a slash on the end of any dept in a location that doesn't have one e.g.
RewriteRule ^([a-zA-Z0-9]+)$ $1/ [R,L]
but this doesn't seem to quite work. What happens, is, if my URL is [127.0.0.1:83...]
I end up with
[127.0.0.1:83...]
somehow, the name of the web dev folder appears i.e. "web".
Any thoughts on that one?
RewriteRule ^([a-zA-Z0-9]+)$ [b]http://www.example.com/[/b]$1/ [[b]R=301[/b],L]
RewriteRule ^([^/.]+)$ http://www.example.com/$1/ [R=301,L]
-or-
RewriteRule ^([^a-z0-9]+)$ http://www.example.com/$1/ [[b]NC[/b],R=301,L]