Atif
Atif

Reputation: 10880

.htaccess redirect to a directory

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

Upvotes: 0

Views: 257

Answers (1)

Amber
Amber

Reputation: 526593

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

Upvotes: 1

Related Questions