Link to home
Start Free TrialLog in
Avatar of Witheet
WitheetFlag for Netherlands

asked on

Browser caching upload folder htaccess on linux server

Hello experts,

I am using a htaccess file for browser caching/ gzip /url rewrites.
I ussually use windows hosting where I can drop it in the root folder...
However now on a linux server when I try to upload it to the cgi-bin folder inside public_html folder it does nothing.
When uploaded to the root of public_html it generates a 500-error

Is the cgi-bin in the public_html folder the right location to upload this file or are there errors inside my rules?

Any help will be much appreciated!...

WKR RV

////

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
#ACTIVATE IMAGE CACHING ON STATIC SITES
#ExpiresByType image/jpg "access 1 month"
#ExpiresByType image/jpeg "access 1 month"
#ExpiresByType image/gif "access 1 month"
#ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
#ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access plus 1 month"  
ExpiresByType application/javascript "access plus 1 month"  
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
#ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/x-font-ttf    "access plus 1 month"
ExpiresByType font/opentype             "access plus 1 month"
ExpiresByType application/x-font-woff   "access plus 1 month"
ExpiresByType image/svg+xml             "access plus 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

RewriteEngine On
RewriteBase
RewriteRule ^/.*-N([0-9]+)\.html$ ../post/index.php?N_ID=$1 [L]
Avatar of arnold
arnold
Flag of United States of America image

Is this shared hosting? Check the error log, permissions on the .htaccess file
cgi-bin is running scripts, not sure it can .....
At which point do you get the 500 error?
Avatar of Witheet

ASKER

Hello Arnold, Thank you for your reply.

It is shared hosting and the 500 error occurs when i upload htaccess to the root folder(public_html).
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Witheet

ASKER

Thank you very much David.

I can now upload the file without it causing a 500-error and both gzip and caching seem to work now...
BUT
The rewritten url now gives a 404 not found message.
Can you maybe tell me if I need to change a path there or is it something else?
Ive tried:
/post
./post
../post

///

RewriteEngine On
RewriteBase  /
RewriteRule ^/.*-N([0-9]+)\.html$ ../post/index.php?N_ID=$1 [L]
Avatar of Witheet

ASKER

Ps. I uploaded it to the root folder not the cgi-bin...
What is ../post/index.php?

Your rule is / changing it to ?

../ means move one folder up.
Excellent!

And be sure to note Witheet's comment. You .htaccess file belongs in your DocumentRoot, rather than cgi-bin directory.

Also as arnold asked, post an exact link you expect to visit + exactly how you'd like your Rewrite this link.
Avatar of Witheet

ASKER

Thank you very much for your responses!!!

I simply added the / to RewriteBase like David suggested and that made the site not crash anymore on that 500-error.
The caching is now active so is gzip but just not the url rewrite

../post/index.php is a dynamic page that fetches articles from a database
Original URl would be:
http://www.domain.com/post/index.php?N_ID=5
Rewritten URL would then become something like:
 http://www.domain.com/post/title-post-here-N5.html

I've tried the following paths on the rewriterule:
../post/index.php?N_ID=$1 [L]
/post/index.php?N_ID=$1 [L]
post/index.php?N_ID=$1 [L]
But no result...

Any suggestions?

WKR RV
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Witheet

ASKER

Thank you Arnold.
I had to change it to this to get it working.
RewriteEngine on
RewriteBase /
RewriteRule ^post/.*\-N([0-9]+)\.html$ /post/index.php?N_ID=$1 [L]

Open in new window

Avatar of Witheet

ASKER

Thank you very much for your help!