views:

70

answers:

1

This is a very silly question but I am pretty weak in htaccess.

I want all files (php, css, javascripts and images) located at http://localhost/template/* to point to http://localhost/* along with a 404 Error Handler that is located at http://localhost/tempalte/404.php

I almost got it here but when I change

RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] to
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1.$2 [NC,L]

I get an internal server error.

# BEGIN website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(css|php|js|png|gif) template/$1 [NC,L] 
</IfModule>

Options -Indexes
# END website
+1  A: 

Edited to reflect comments, try this:

# BEGIN website
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*\.(css|php|js|png|gif)) template/$1 [NC,L] 
</IfModule>

Options -Indexes
# END website
Amber
hi dav, it doesnt seem to work, I get this The requested URL /login.php was not found on this server.
atif089
What URL are you entering in your browser, and what path on the server do you expect it to load?
Amber
Let me clarify what I'm trying to determine here. Usually when one says you want A to point to B, it means the thing that *actually* exists is at B, and A is just a link to something that's actually at B. In my answer above, I went with what your words specified (that you wanted URLs including /template/ to point to something that *actually* existed in the root directory). However, judging from your examples, I'm wondering if what you actually meant is that you wanted URLs in the root directory to point to something that *actually* exists in the /template/ directory?
Amber
exactly.. i guess my question was wrong.. so can you help me with this ?
atif089
I want http://localhost/login.php to load http://localhost/template/login.php
atif089
Yes. I'll edit my answer, give me a moment.
Amber