.htaccess

Parsing an .htaccess File With PHP

I am using the Zend Framework, and I use the .htaccess for some settings. I am now writing command line scripts for scheduling (e.g. cron). Command line scripts don't look at the .htaccess file because they're not served up by Apache. I would like to parse the .htaccess with my script to retrieve some settings. Here are the lines I'm...

@font-face and Header set Access-Control-Allow-Origin "*"

I have used the following rule to allow our static domain to host fonts, but I've run into a problem font's not being used by the browser (firefox, safari) when the browser cache is enabled. <Directory "/site/http/web/assets/fonts"> <FilesMatch "\.(eot|otf|woff|ttf)$"> SetEnvIf Origin "^http://(.*)?main-domain.co...

htaccess: Rewrite collision - simple question

This row will certainly cause a little collision as it will try to rewrite the goal itself: RewriteRule ^/(.*)$ page.php?q=$1 [L,NC] Now, how do I prevent this? ...

setting up file restriction by IP using .htaccess on a cluster/cloud environment

found answer, see end of the post How do you restrict access to a file by IP, when you are hosted in a cluster/cloud environment (Rackspace Cloud, to be more specific). Yesterday, I asked a similar question here, and received the following answer, which worked great (thank you) in my local test environment. <Files test.html> Order...

Redirect all links below a subdirectory to a "out of service" page?

I have a directory full of email forms in various subdirectories, linked by various people in various places. I recently found a security problem in some of the forms, and I've taken them all offline, but now when people go to the links they get 404 errors. Is there an easy way, with .htaccess perhaps, to redirect any request for mydom...

how can i redirect via htaccess

hi guys, i want to redirect http://abc.com/a to /mypage.php?par1=a and http://abc.com/a/b to /mypage.php?par1=a&par2=b how can it be done? ...

Add expires header without mod_expires?

I know that I can add expires header using mod_expires. However, what can I do if the Apache server doesn't have mod_expires installed and I don't want to route the access to the files through a scripting language like PHP? ...

Forcing a trailing slash to a URL after a subdomain rewrite

Hi There, I'm re-writing a subdomain to a 'folder' - actually a page in wordpress, and this all seems to be working correctly. I don't want the address in the URL bar to change though. Everything works fine unless the user does not put a trailing slash after the page name, then the page is still redirected to the correct URL but the U...

Using custom environment variables in .htaccess

I need something like this: SetEnv foo bar.baz RewriteEngine On RewriteCond %{HTTP_HOST} ^%{foo}$ RewriteRule ^(.*)$ http://www.foo/$1 [L] UPD: I have made as follows: SetEnv HOSTNAME_ENV testsite RewriteEngine On RewriteCond %{HTTP_HOST} ^%{ENV:HOSTNAME_ENV} RewriteRule ^(.*)$ http://www.%{ENV:HOSTNAME_ENV}/$1 [L,R=301] But it d...

redirect all links to include a segment in front of the main url

I setup a local website using mamp, there are other sites I run in development on the same mamp install and I use links on my site like <a href="/about">About</a> It will direct the user to http://localhost/about, but I need it to direct to http://localhost/chuck/host chuck is the folder that this site is within, file path: /Applicatio...

redirect without htaccess

i have a site that is on a darwin server. i dont see any .htaccess.(i can see .htaccess file in a different site on the same server.) yet it redirects /file to /file.php how is this done? ...

htaccess question

I have setup htaccess but i want increase the length of the rule so i need to know can i bypass one files, its currently 4 but i want to extend to 11- file i want to bypass is called shorten.php can i name a file that escapes the rule? RewriteCond %{REQUEST_URI} \/([0-9a-z]{4})$ [NC] RewriteRule ^(.*) http://www.x/forward.php?%1 [L]...

Is it vital to have an index page in your root eg index.html, index.php

I have and index.php page in my root that simple directs to what I would consider my homepage, like so: <? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: /lake-district-cottages/" ); ?> is it best to just remove the index page and set my true index in my htaccess or is it required that I have a file called index? ...

Specific web page started to occasionally result in 500 internal error

Hi, I've come across an issue today where a specific page on my site is sometimes causing a 500 internal error. The page normally can take fairly long to load due to some database queries on large datasets, but only today has the apache 500 internal error started to happen. Obviously I will try to optimise the db queries as much as possi...

How to turn all variables in a url into a nice url with .htaccess?

I have a page with urls with lot of variables, for example: http://dev.resihop.nu/addtrip?from=stockholm&amp;to=goteborg&amp;when=2010-09-06&amp;got_car=1 How do I make it so that it instead gets written like this: http://dev.resihop.nu/addtrip/from/stockholm/to/goteborg/when/2010-09-06/got_car/1 extra awesome features! (I'd be really...

correct way to redirect changed site location via .htaccess

i used to host my site at www.mysite.com/here now the url is simply www.mysite.com so how do i properly redirect all old links from say www.mysite.com/here/about to www.mysite.com/about thanks. ...

problems working with 'rewrite' in apache2

I have the following list of URLs to rewrite: 1 write url /products/client/ send to /basedir/system/index.php?client=cliente 2 write url /product/client/index.php send to /basedir/system/index.php?client=cliente 3 write url /products/client/image/dir2/myimage.jpg send to /basedir/system/image/client/dir2/myimage.jpg 4 ...

.htaccess rewrite, how do I do it for this senario?

Hi there, I would like to have eg. www.domain.com/api/json/implode/abc/and/a/b/c... equal to www.domain.com/api/jason/?method=implode&key=abc&param1=and&param2=a&param3=b&param4=c... cheers James ...

How to read images from a folder with htaccess file

Hello, I am using the readfile function to read image files. It works in most cases except when an image is located in a directory with htaccess file. Here is an example: header("Content-type: image/jpeg"); ob_clean(); // clean output buffer flush(); // flush output buffer readfile("http://127.0.0.1/WebProjects/project1/data/media/im...

urldecode with mod_rewrite

Hi, I would like to decode requested URL via .htaccess/mod_rewrite and forward it to my PHP application. I am making request to some remote service and I need to preserve the URL for redirecting after processing the remote request. I am handling it over in forward GET parameter so I need to encode it via urlencode. I would like it decode...