Search Results

Search found 2190 results on 88 pages for 'htaccess'.

Page 22/88 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • .htaccess - deny downloading of files

    - by user317005
    I keep several fonts in the directory "/fonts/" on my server which I then load into my css files via @font-face. However, I want to make sure that people cannot download the file just by simply going to http://www.domain.com/fonts/fontname.ttf. Can I somehow prevent this, and still be able to load the font files into my css files? Because I think putting deny from all into the .htaccess file will even prevent the css files for correctly loading the fonts. I hope this makes sense.

    Read the article

  • problem with .htaccess and mod_rewrite

    - by ian
    My below .htaccess file should send everything to my index.php page where my framework [Fat Free Frameowkr] handles it. However if I go to http://www.site.com/ it works. If I go to http://www.site.com/about I get a 404 error. Any ideas? # Enable rewrite engine and route requests to framework RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,QSA] # Disable ETags Header Unset ETag FileETag none # Default expires header if none specified (stay in browser cache for 7 days) <IfModule mod_expires.c> ExpiresActive On ExpiresDefault A604800 </IfModule>

    Read the article

  • .htaccess redirect question

    - by russp
    I have a slight problem with .htaccess redirect. I have a dynamic site with 2 levels of variables - content="type -(alpha)" and ID="number" but this is very not seo friendly what I really would like to create is a rewrite rule that generates a "friendly" url for serach engines & users alike. Very much like WordPress does. Each ID is already unique (obviously) and on creation is creating a unique "permalink" field so for example ID=1 has a "permalink field" as "2009/10/27/page title" and ID=100 would be "2010/10/27 page title". I would like folder/wall.php?content=type&ID=number to redirect to folder/permalink.php/html/htm (don't mind a non dynamic extension) Any clues? - this is not right (I know) but it also "breaks" my css file RewriteEngine On RewriteRule wall/content/(.*)/ID/(.*)/ wall.php?content=$1&ID=$2 RewriteRule wall/content/(.*)/ID/(.*) wall.php?content=$1&ID=$2

    Read the article

  • RewriteCond and RewriteRule in .htaccess

    - by RD
    I have a client folder located at http://www.example.com/client However, I've now installed SSL on the server, and want to add a permanent redirect using HTACCESS so that whenever /client is accessed, that it redirects to: https://www.example.com/client Anybody know how to do that? I've redirected my domains in the past like this: RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^www.example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] This should not affect the solution, but the site must still redirect to www.example.com FIRST, and then to https://www.example.com/client if for example, http://www.example.co.za/client is entered.

    Read the article

  • HTACCESS redirection with a word replacement in url

    - by Marwen
    I'm having trouble with this reg expression which i belive is correct, but it is not working. What im trying to do is redirect bunch of urls containing a specific string like this: http://www.example.com/**undesired-string**_another-string to http://www.example.com/**new-string**_another-string and http://www.example.com/folder/**undesired-string**/another-string to http://www.example.com/folder/**new-string**/another-string So i have this code in the .htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule (.+)+(undesired-string)+(.+) $1new-string$2 [R=301,L] </IfModule> This should replace ANY undesired-string in any url to new-string, but it is not working, any idea why ? Thank you

    Read the article

  • How to successfully Rewrite a URL with .htaccess

    - by Ian Storm Taylor
    Hello. I am trying to rewrite mysite.com/broadcasts to mysite.com/feed so that it will show up in the location bar as "broadcasts" but actually go to /feed. Here is what I have in the .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^broadcasts(/)?$ /feed/ </IfModule> But this isn't working... I get a 404 error. Wondering if I'm doing something stupidly wrong. Thanks!

    Read the article

  • getting error 500 with .htaccess when pointing an existing file / folder (mod_rewrite)

    - by Leto
    i made a simple .htaccess file to expose the problem. I want that all request made to the folder redirect to a subfolder file "app/index.php" RewriteEngine On RewriteRule (.*) app/index.php [QSA] And this works fine on with the basic url of my hoster (like http//myname.hosting.com/htaccessFolder The problem is that i have a domain pointing on this folder, and when accessed to it, server return Internal Server Error 500. If i do this : RewriteEngine On RewriteRule (.*) somefile.php [QSA] Redirection works only when file does not exists (404 not found error occured). when the file exists i get a 500 error too. I've asked the hosting support without success for the moment..

    Read the article

  • cakephp htaccess for production install

    - by Joshua Foxworth
    So, I have cakephp installed in what I believed to be the appropriate way for production code with actual cake files above the public_html folder. The app folder is removed from the cake folder and placed at the same level. Loading the home page works fine with the databases and the debug working. However, in trying to run some test files I get a 404. Obviously, I need some way to direct something like www.example.com/posts/index to the proper location. I am not sure as to why this is necessary since the index.php file tells cake where the app directory is located? Also, if I need to use the .htaccess file, how do I point to the proper location and exactly what am I pointed at?

    Read the article

  • magento .htaccess password protect inner pages (not homepage)

    - by Angel Wong
    I would like to use .htaccess to password protect all inner pages of Magento, except the home page. e.g. http://www.example.com/abc (password protect) http://www.example.com (home page, no need to password protect) I tried to use the setifenv request_uri = "/" => allow, but didn't work. It still password protect all pages including the homepage. I also tried a few ways inside the Magento admin URL rewrite, but those won't work either. Any expert can help? thx E

    Read the article

  • Can the .htaccess file slow down a website to a crawl? If so, are there better ways to solve these problems with different rewrite rules and such?

    - by Parimal
    here is my htaccess file...... RewriteCond %{REQUEST_URI} ^/patients/billing/FAQ_billing\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/billing/getintouch\.html$ RewriteRule ^patients/billing/(.*)\.html$ $1.php [L,NC] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/a\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/b\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/c\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/d\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/e\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/f\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/g\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/h\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/i\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/j\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/k\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/l\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/m\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/n\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/o\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/p\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/q\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/r\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/s\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/t\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/u\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/v\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/w\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/x\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/y\.html$ [OR] RewriteCond %{REQUEST_URI} ^/patients/findadoctor/z\.html$ RewriteRule ^patients/findadoctor/(.*)\.html$ findadoctor.php?id=$1 [L,NC] like that there is lots of rules around 250 line please help me...

    Read the article

  • How expensive is a hostname in htaccess? Other solutions possible?

    - by Nanne
    For easy allow or disallowing of dynamic IP-adresses you can add them as a hostname in a .htaccess file. As I have read from: .htaccess allow from hostname? it does a reverse lookup on the connecting ip address, seeing if the response matches the allowed name. (Well, actually Apache is doing a double lookup, first a reverse lookup and then a forward lookup on the result of the reverse.) This is the reason we are currently not using dynamic-ip hostnames in the .htaccess: this "sounds" quite heavy: 2 extra lookups for every request. Is this indeed quite heavy, and would a reasonably busy server that is rather looking for less then more load get away with this :)? (e.g.: how does this 'load' compare to the rest? If a request is 1000 times more expensive then the lookups it might be negligible. otoh, it could be that final straw :) ) Are there other solutions? I can write a script that does a lookup of the hostname and put it in .htaccess files ofcourse, but this feels a bit like a hack.

    Read the article

  • .htaccess equivalent of baseurl?

    - by Ryan
    Hello, I'm trying to install Symfony on a shared server and am attempting to duplicate the httpd.conf command: # Be sure to only have this line once in your configuration NameVirtualHost 127.0.0.1:8080 # This is the configuration for your project Listen 127.0.0.1:8080 <VirtualHost 127.0.0.1:8080> DocumentRoot "/home/sfproject/web" DirectoryIndex index.php <Directory "/home/sfproject/web"> AllowOverride All Allow from All </Directory> Alias /sf /home/sfproject/lib/vendor/symfony/data/web/sf <Directory "/home/sfproject/lib/vendor/symfony/data/web/sf"> AllowOverride All Allow from All </Directory> </VirtualHost> I need to do so using .htaccess The redirect portion was done in the root using the following: Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^symfony.mysite.ca [nc] rewriterule ^(.*)$ http://symfony.mysite.ca/web/$1 [r=301,nc] For the alias, I've tried using: RewriteBase / but no success. The main issue is that the index.php file residing in the /web folder uses the /web path in its path to images and scripts. So instead of href="/css/main.css" //this would work it uses href="/web/css/main.css" //this doesn't work, already in the /web/ directory! Any ideas? Thanks!

    Read the article

  • CodeIgniter, Godaddy, htaccess passing variable through url, HMVC

    - by user1492738
    I have a new controller in a module created with HMVC (admin), but i tried also without HMVC and the same issue. I am trying to pass a variable to index or another method from controller but when i access it i receive 404 error, not found. I am new to Codeigniter. I am trying to do resolve this since yesterday, please help me :) Thank you! Route: $route['default_controller'] = 'pages/view/home'; -- working $route['(:any)'] = "pages/view/$1"; -- working $route['404_override'] = ''; -- working $route['admin'] = 'admin/index'; -- working $route['admin/list'] = 'admin/list_pages/index'; -- working $route['admin/edit/(:any)'] = 'admin/edit/index/$1'; -- this is the problem, the other rules are working HTACCESS: RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 [L] Controller: class Edit extends CI_Controller{ function __construct() { parent::__construct(); $this->load->model('pages_model'); } function index($id = 0){ $data['page'] = $this->pages_model->get_pages_by_id($id); $this->load->view('header', $data); $this->load->view('edit', $data); $this->load->view('footer', $data); } } Config: $config['base_url'] = ''; $config['index_page'] = 'index.php?'; $config['uri_protocol'] = 'QUERY_STRING';

    Read the article

  • Using htaccess rewrite/redirect so single PHP file can display data according to GET/POST variables

    - by revive
    Hey gang, Bear with me as I try to learn more about .htaccess redirect rules - I'm a UI guy by profession and I'm doing my best to enhance my coding skills languages other than HTML/CSS/PHP, etc So, what I have is an index.php file that contains a menu - pretty simple. If Javascript is enabled on the users computer then forms are shown below the menu using simple jQuery goodies, with each link having a 'return false;' applied. What I am trying to do is make the page accessible with JS turned off, so instead of redirecting the user to a different page, I would like to use POST or GET variables from each link, to show the various forms.. within the same index.php file - but have the URL reflect the menu choice Here is an example using menu items named - Home, About, Form1 and Form2: With JS on, clicking on of the above example buttons simply slides the form or containing the data down onto the page. With JS off, if the user clicks the 'About' link, I would like to rewrite the URL to be http://domain.com/about - but keep the user on the index.php page (since it is the only page) and be able to use POST or GET variable to show the using PHP. So, accessing http://domain.com/index.php?page=about would show http://domain.com/about in the URL but pass the GET variable 'page' to the index.php file. Hope that makes sense.. and I'm sure there are many ways to accomplish this, so if you have ideas of how to improve on it, by all means, I'd love to hear it ! Thanks again Revive

    Read the article

  • Redirect Desktop Internal Pages to Correct Mobile Internal Pages with Htaccess

    - by Luis Alejandro Ramrez Gallardo
    I have built a Mobile site in a sub-domain. I have successfully implemented the redirect 302 from: www.domain.com to m.domain.com in htaccess. What I'm looking to achieve now it to redirect users from: www.domain.com/internal-page/ > 302 > m.domain.com/internal-page.html Notice that URL name for desktop and mobile is not the same. The code I'm using looks like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress # Mobile Redirect # Verify Desktop Version Parameter RewriteCond %{QUERY_STRING} (^|&)ViewFullSite=true(&|$) # Set cookie and expiration RewriteRule ^ - [CO=mredir:0:www.domain.com:60] # Prevent looping RewriteCond %{HTTP_HOST} !^m.domain.com$ # Define Mobile agents RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR] RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR] RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC] # Verify if not already in Mobile site RewriteCond %{HTTP_HOST} !^m\. # We need to read and write at the same time to set cookie RewriteCond %{QUERY_STRING} !(^|&)ViewFullSite=true(&|$) # Verify that we previously haven't set the cookie RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC] # Now redirect the users to the Mobile Homepage RewriteRule ^$ http://m.domain.com [R] RewriteRule $/internal-page/ http://m.domain.com/internal-page.html [R,L]

    Read the article

  • Efficient Method for Preventing Hotlinking via .htaccess

    - by Michael Robinson
    I need to confirm something before I go accuse someone of ... well I'd rather not say. The problem: We allow users to upload images and embed them within text on our site. In the past we allowed users to hotlink to our images as well, but due to server load we unfortunately had to stop this. Current "solution": The method the programmer used to solve our "too many connections" issue was to rename the file that receives and processes image requests (image_request.php) to image_request2.php, and replace the contents of the original with <?php header("HTTP/1.1 500 Internal Server Error") ; ?> Obviously this has caused all images with their src attribute pointing to the original image_request.php to be broken, and is also the wrong code to be sending in this case. Proposed solution: I feel a more elegant solution would be: In .htaccess If the request is for image_request.php Check referrer If referrer is not our site, send the appropriate header If referrer is our site, proceed to image_request.php and process image request What I would like to know is: Compared to simply returning a 500 for each request to image_request.php: How much more load would be incurred if we were to use my proposed alternative solution outlined above? Is there a better way to do this? Our main concern is that the site stays up. I am not willing to agree that breaking all internally linked images is the best / only way to solve this. I refuse to tell our users that because of something WE changed they must now manually change the embed code in all their previously uploaded content.

    Read the article

  • .htaccess redirect or rewrite to default language url

    - by Saif Bechan
    I have a website that is currently in Dutch. Now I want to make the website multi-language starting with English. I am not that good at .htaccess files and the information on the web is quite confusing. The website I have now uses pretty urls, so all my urls look like this: http://mydomain.com/about/info http://mydomain.com/about/contact The code that I use for that is the following: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA] </IfModule> I really do not know what this means, esp the [L,QSA]. But it's ok, it works for now. But now I want to add a default redirect to the code. So it becomes as follow http://mydomain.com becomes http://mydomain.com/nl I assume all my old links http://mydomain.com/about/info will not work anymore, but that is a step I am willing to take. Can someone please help me with this code. I have seen a lot of peaces of code, but I can not find the right one.

    Read the article

  • Django install on a shared host, .htaccess help

    - by redconservatory
    I am trying to install Django on a shared host using the following instructions: docs.google.com/View?docid=dhhpr5xs_463522g My problem is with the following line on my root .htaccess: RewriteRule ^(.*)$ /cgi-bin/wcgi.py/$1 [QSA,L] When I include this line I get a 500 error with almost all of my domains on this account. My cgi-bin directory is home/my-username/public_html/cgi-bin/ The wcgi.py file contains: #!/usr/local/bin/python import os, sys sys.path.insert(0, "/home/username/django/") sys.path.insert(0, "/home/username/django/projects") sys.path.insert(0, "/home/username/django/projects/newprojects") import django.core.handlers.wsgi os.chdir("/home/username/django/projects/newproject") # optional os.environ['DJANGO_SETTINGS_MODULE'] = "newproject.settings" def runcgi(): environ = dict(os.environ.items()) environ['wsgi.input'] = sys.stdin environ['wsgi.errors'] = sys.stderr environ['wsgi.version'] = (1,0) environ['wsgi.multithread'] = False environ['wsgi.multiprocess'] = True environ['wsgi.run_once'] = True application = django.core.handlers.wsgi.WSGIHandler() if environ.get('HTTPS','off') in ('on','1'): environ['wsgi.url_scheme'] = 'https' else: environ['wsgi.url_scheme'] = 'http' headers_set = [] headers_sent = [] def write(data): if not headers_set: raise AssertionError("write() before start_response()") elif not headers_sent: # Before the first output, send the stored headers status, response_headers = headers_sent[:] = headers_set sys.stdout.write('Status: %s\r\n' % status) for header in response_headers: sys.stdout.write('%s: %s\r\n' % header) sys.stdout.write('\r\n') sys.stdout.write(data) sys.stdout.flush() def start_response(status,response_headers,exc_info=None): if exc_info: try: if headers_sent: # Re-raise original exception if headers sent raise exc_info[0], exc_info[1], exc_info[2] finally: exc_info = None # avoid dangling circular ref elif headers_set: raise AssertionError("Headers already set!") headers_set[:] = [status,response_headers] return write result = application(environ, start_response) try: for data in result: if data: # don't send headers until body appears write(data) if not headers_sent: write('') # send headers now if body was empty finally: if hasattr(result,'close'): result.close() runcgi() Only I changed the "username" to my username...

    Read the article

  • Implementation problem. Htaccess in php

    - by Irwan
    I have a problem to fix the URL on my website at http://www.abelputra.com I need a solution: I want to change www.abelputra.com/software.php into www.abelputra.com/software I have read a tutorial like this: For .htaccess: RewriteEngine On RewriteRule ^ ([a-zA-Z0-9_-] +) $ index.php? Key = $ 1 RewriteRule ^ ([a-zA-Z0-9_-]+)/$ index.php? Key = $ 1 Then in php: index.php --- $Key=$ _GET ['key']; if ($key == 'home') { include ('index.php'); // Home page } else if ($ key == 'software') { include ('software.php'); // } else if ($ key == 'webdesign') { include ('webdesign.php'); // } The problem is: When I implemented the menu software.php index.php to call the page: www.abelputra.com/index.php?key=software what happens is the page that is shown is two pages later software.php index.php page underneath. Is it because calling functions "include ()"? index.php structures: Header Content - contains the opening words Footer software.php structure: Header Content - contains an explanation of my software Footer Sorry my english bad. im from Indonesia. Please solution .. thanks

    Read the article

  • .htaccess trickery multi-language website

    - by user1658741
    I have a website right now that uses two languages (french and english) The way it works right now is that if someone goes to mysite.com/folder/file.php for example, file.php is simply a script that figures out which language to use, get's it's own path and filename(file.php) and serves up mysite.com/en/folder/file.php (if the language is english). However what shows up in the URL is still mysite.com/folder/file.php. For any folder and any file the same script is used. If I want to add a new file I have to add the file to the folder the user types into the browser as well to the en and fr folders. Could I do some .htaccess trickery so that whatever URL is typed, one .php file gets open that checks the language and what folder/file was requested and then serves up the correct language file? here's the php file that is served up for any files in the URL. <?php // Get current document path which is mirrored in the language folders $docpath = $_SERVER['PHP_SELF']; // Get current document name (Used when switching languages so that the same current page is shown when language is changed) $docname = GetDocName(); //call up lang.php which handles display of appropriate language webpage. //lang.php uses $docpath and $docname to give out the proper $langfile. //$docpath/$docname is mirrored in the /lang/en and /lang/fr folders $langfile = GetDocRoot()."/lang/lang.php"; include("$langfile"); //Call up the proper language file to display function GetDocRoot() { $temp = getenv("SCRIPT_NAME"); $localpath=realpath(basename(getenv("SCRIPT_NAME"))); $localpath=str_replace("\\","/",$localpath); $docroot=substr($localpath,0, strpos($localpath,$temp)); return $docroot; } function GetDocName() { $currentFile = $_SERVER["SCRIPT_NAME"]; $parts = Explode('/', $currentFile); $dn = $parts[count($parts) - 1]; return $dn; } ?>

    Read the article

  • Use .htaccess to block *All* access to specific folders.

    - by Urda
    I am not sure how to do this, but I want to block all access to a specific set of folders on my web server. Say secret01 and secret 02... homeDir |- data |- www | |- .htaccess (file) | |- images | |- js | |- secret01 | |- secret02 | |... |... What rule(s) do I need to add to my root .htaccess file to do this? I want all access from the web blocked from going into these folders, period. Only way one could get to them would be over SFTP or SSH. So what rule am I looking for? I am preferably looking for a one-liner so I can add more folders or move it to another site down the road. I really would prefer if the rule could be placed in the .htaccess root file so I don't have to jump all over the place to lock and unlock folders.

    Read the article

  • Optimized .htaccess???

    - by StackOverflowNewbie
    I'd appreciate some feedback on the compression and caching configuration below. Trying to come up with a general purpose, optimized compression and caching configuration. If possible: Note your PageSpeed and YSlow grades Add configuration to your .htaccess Clear your cache Note your PageSpeed and YSlow grades to see if there are any improvements (or degradations) NOTE: Make sure you have appropriate modules loaded. Any feedback is much appreciated. Thanks. # JavaScript MIME type issues: # 1. Apache uses "application/javascript": http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types # 2. IIS uses "application/x-javascript": http://technet.microsoft.com/en-us/library/bb742440.aspx # 3. SVG specification says it is text/ecmascript: http://www.w3.org/TR/2001/REC-SVG-20010904/script.html#ScriptElement # 4. HTML specification says it is text/javascript: http://www.w3.org/TR/1999/REC-html401-19991224/interact/scripts.html#h-18.2.2.2 # 5. "text/ecmascript" and "text/javascript" are considered obsolete: http://www.rfc-editor.org/rfc/rfc4329.txt #------------------------------------------------------------------------------- # Compression #------------------------------------------------------------------------------- <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml # The following MIME types are in the process of registration AddOutputFilterByType DEFLATE application/xslt+xml AddOutputFilterByType DEFLATE image/svg+xml # The following MIME types are NOT registered AddOutputFilterByType DEFLATE application/mathml+xml AddOutputFilterByType DEFLATE application/rss+xml # Deal with JavaScript MIME type issues AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE text/ecmascript AddOutputFilterByType DEFLATE text/javascript </IfModule> #------------------------------------------------------------------------------- # Expires header #------------------------------------------------------------------------------- <IfModule mod_expires.c> # 1. Set Expires to a minimum of 1 month, and preferably up to 1 year, in the future # (but not more than 1 year as that would violate the RFC guidelines) # 2. Use "Expires" over "Cache-Control: max-age" because it is more widely accepted ExpiresActive on ExpiresByType application/pdf "access plus 1 year" ExpiresByType application/x-shockwave-flash "access plus 1 year" ExpiresByType image/bmp "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType image/tiff "access plus 1 year" ExpiresByType image/x-icon "access plus 1 year" ExpiresByType text/css "access plus 1 year" ExpiresByType video/x-flv "access plus 1 year" # Deal with JavaScript MIME type issues ExpiresByType application/javascript "access plus 1 year" ExpiresByType application/x-javascript "access plus 1 year" ExpiresByType text/ecmascript "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" # Probably better to explicitly declare MIME types than to have a blanket rule for expiration # Uncomment below if you disagree #ExpiresDefault "access plus 1 year" </IfModule> #------------------------------------------------------------------------------- # Caching #------------------------------------------------------------------------------- <IfModule mod_headers.c> <FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|js|pdf|png|svg|swf|tif|tiff)$"> Header add Cache-Control "public" Header unset ETag Header unset Last-Modified FileETag none </FilesMatch> </IfModule>

    Read the article

  • Use a subdirectory as root with htaccess in Apache 1.3

    - by Andrew
    I'm trying to deploy a site generated with Jekyll and would like to keep the site in its own subfolder on my server to keep everything more organized. Essentially, I'd like to use the contents of /jekyll as the root unless a file similarly named exists in the actual web root. So something like /jekyll/sample-page/ would show as http://www.example.com/sample-page/, while something like /other-folder/ would display as http://www.example.com/other-folder. My test server runs Apache 2.2 and the following .htaccess (adapted from http://gist.github.com/97822) works flawlessly: RewriteEngine On # Map http://www.example.com to /jekyll. RewriteRule ^$ /jekyll/ [L] # Map http://www.example.com/x to /jekyll/x unless there is a x in the web root. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/jekyll/ RewriteRule ^(.*)$ /jekyll/$1 # Add trailing slash to directories without them so DirectoryIndex works. # This does not expose the internal URL. RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME} !/$ RewriteRule ^(.*)$ $1/ # Disable auto-adding slashes to directories without them, since this happens # after mod_rewrite and exposes the rewritten internal URL, e.g. turning # http://www.example.com/about into http://www.example.com/jekyll/about. DirectorySlash off However, my production server runs Apache 1.3, which doesn't allow DirectorySlash. If I disable it, the server gives a 500 error because of internal redirect overload. If I comment out the last section of ReWriteConds and rules: RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME} !/$ RewriteRule ^(.*)$ $1/ …everything mostly works: http://www.example.com/sample-page/ displays the correct content. However, if I omit the trailing slash, the URL in the address bar exposes the real internal URL structure: http://www.example.com/jekyll/sample-page/ What is the best way to account for directory slashes in Apache 1.3, where useful tools like DirectorySlash don't exist? How can I use the /jekyll/ directory as the site root without revealing the actual URL structure? Edit: After a ton of research into Apache 1.3, I've found that this problem is essentially a combination of two different issues listed at the Apache 1.3 URL Rewriting Guide. I have a (partially) moved DocumentRoot, which in theory would be taken care of with something like this: RewriteRule ^/$ /e/www/ [R] I also have the infamous "Trailing Slash Problem," which is solved by setting the RewriteBase (as was suggested in one of the responses below): RewriteBase /~quux/ RewriteRule ^foo$ foo/ [R] The problem is combining the two. Moving the document root doesn't (can't?) use RewriteBase—fixing trailing slashes requires(?) it… Hmm…

    Read the article

  • Htaccess rewrite rule .aspx to .php

    - by Markus Ossi
    Background: I have a website that has been built with ASP.NET 2.0 and is on Windows hosting. I now have to rewrite my site in PHP and move it into Linux hosting. I have a lot of incoming links to my site from around the web that point directly into the old .aspx-pages. The site itself is very simple, one dynamic page and five static ones. I saved the static .aspx pages as .php-pages and rewrote the dynamic page in PHP. The dynamic page is called City.aspx and I have written it in PHP and it is now called City.php. On my old Windows hosting, I used ASP.NET's URL mapping for friendly URL. For example, incoming URL request for Laajakaista/Ypaja.aspx was mapped into City.aspx?CityID=981. My goal: To redirect all human visitors and search engines looking for the old .aspx pages into the new .php pages. I am thinking that the easiest way to redirect visitors into new pages will be by making a redirect, where all requests for .aspx-files will be redirected into .php filetypes. So, if someone asks for MYSITE/City.aspx?CityID=5, they will be taken into MYSITE/City.php?CityID=5 instead. However, I am having a lot of trouble getting this to work. So far this is what I have found: rewriterule ^([.]+)\.aspx$ http://www.example.com/$1.php [R=301,L] However, I think this can not handle the parameters after the filetype and I am also not quite sure what to put on front. To make things a bit more complicated, at my previous site I used friendly URL's so that I had a huge mapping file with mappings like this: <add url="~/Laajakaista/Ypaja.aspx" mappedUrl="~/City.aspx?CityID=981" /> <add url="~/Laajakaista/Aetsa.aspx" mappedUrl="~/City.aspx?CityID=988" /> <add url="~/Laajakaista/Ahtari.aspx" mappedUrl="~/City.aspx?CityID=989" /> <add url="~/Laajakaista/Aanekoski.aspx" mappedUrl="~/City.aspx?CityID=992" /> I tried to make a simple redirect like this: Redirect 301 Laajakaista/Aanekoski.aspx City.php?CityID=992 but was not able to get it to work. I ended up with an internal server error and a 50k .htaccess-file... Any help is greatly appreciated.

    Read the article

  • Exclude a sub directory in a protected directory

    - by user1351358
    I need to exclude protection on one of the folder inside a protected directory with .htaccess I put .htaccess in here: /home/mysite/public_html/new/administrator/.htaccess The directory need to be exclude from protection: /home/mysite/public_html/new/administrator/components/com_phocagallery/ My .htaccess file : AuthUserFile "/home/mysite/.htpasswds/public_html/new/administrator/passwd" AuthType Basic AuthName "admin" require valid-user SetEnvIf Request_URI "(/components/com_phocagallery/)$" allow Order allow,deny Allow from env=allow Satisfy any I tried but not working on my purpose. I suspect my path to the excluded directory may have some mistakes. Please advise me. Thanks.

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >