Tag Archives: .htaccess

.htaccess not working – only caching images and not JS or CSS [duplicate]

Questions: Duplicate: Why isn’t my javascript & css caching ? I’m noticing that I’m only receiving 304 HTTP codes (cached content) for images but not JavaScript or CSS. My .htaccess file is: Options -Indexes Options +FollowSymLinks # Enable ETag FileETag MTime Size # Set expiration header ExpiresActive on ExpiresDefault “access plus 1 week” # Compress… Read More »

Rewrite query string in .htaccess

Questions: I’m trying to do a very simple rewrite of a query string and I’m having no luck at all. I need to go from http:// example dot com/?ACT=jquery to http:// example dot com/index.php?ACT=jquery This is the code that I’ve written in my .htaccess file and it throws me an internal server error. I’m really… Read More »

Simple .htaccess RewriteRule not working

Questions: Not sure why this isn’t working: RewriteEngine On RewriteCond %{HTTP_HOST} example.com$ [NC] RewriteRule ^.+ http://example.com [L] The RewriteCond is working as far as I can tell. To me, the RewriteRule reads: ^ Start the match .+ One or more characters Yet, Firefox 44 is telling me The page isn’t redirecting properly Firefox has detected… Read More »

Simple .htaccess subdomain rewrite

Questions: I know there is a lot of questions on here about this… but right now I feel like a deer stunned by oncoming headlights… I just don’t know where to start and which option to choose. My requirements are simple. User goes to http://application.domain.com or http://www.application.domain.com and the real location of these files is… Read More »

How to prevent one file from .htaccess redirect?

Questions: I am creating php front controller. this is my .htaccess file. <IfModule mod_rewrite.c> RewriteEngine on RewriteRule (.*) controller.php [L] </IfModule> This code redirect all url to the controller.php. I need to avoid redirect index.php to the controller.php. All other urls should redirect to the controller.php. Answers: You can use the following syntax to make… Read More »

.htaccess ErrorDocument Redirect

Questions: I am very new to Apache and .htaccess, and I had a simple question regarding how to handle 403 and 404 errors with Apache’s ErrorDocument command. Let’s look at this code from an early CMS I wrote: ErrorDocument 404 /admin/includes/access_deny.php?error=404 This will silently redirect the user to http://www.mysite.com/admin/includes/access_deny.php?error=404 when they get a 404 error.… Read More »

.htaccess in subfolders

Questions: I read tons of topics about this here on SO, but for some reason it not works for me, and I am totally confused. I know, I mess up something, I just cant figure it what. I have a site, and the index.php is calling the router, and show the content that I want.… Read More »

Exclude one file from password protection in .htaccess

Questions: I have the following code to protect files with password in .htaccess: <FilesMatch “\.(html|htm|css|js|php|swf|swz|xml|ico|jpg|jpeg|png|txt)$”> AuthName “Member Only” AuthType Basic AuthUserFile /path/to/password/.htpasswd require valid-user </FilesMatch> How can I exclude from here the should_be_excluded.php from being password protected? I can change the protection lines if needed, but I think that something could be done in the… Read More »