.htaccess

Give no one access in a directory .htaccess

Hi It is probably very simple but I can't find it. I want to make a .htaccess file so no one can get into the folder. except for the php on the server. does anyone know the code line? Thanks Matthy ...

mod_rewrite for clean urls gives 500 internal server error

I'm having some troubles with mod_rewrite. On my index page (index.php) I show a blog and a single blog post page looks like this: http://www.mydomain.com/blog/post-title mod_rewrite for this is: RewriteRule ^blog/([A-Za-z0-9-]+)$ index.php?postslug=$1 [L] This works like a charm. But I also have another page called artists.php and...

Htaccess Redirect

I am looking to make www.purchase.example.com redirect to purchase.example.com, below is an example of what I am trying to do: RewriteCond %{HTTP_HOST} ^www\.purchase\. RewriteRule (.*) http://purchase.DOMAIN_NAME/$1 [L,R] I need a variable that will replace DOMAIN_NAME with simply purchase.example.com. Obviously I can hard code the ...

Grep a string recursively in all .htaccess files

How can I grep for a certain string recursively in all .htaccess files? grep -r -n -H -I 'string' .htaccess doesn't seem to work. I'm on a GNU Linux system. ...

php to htaccess rewrite - redirect if no $_POST data

if( count( $_POST ) < 1 ) { // determine if this was a secure request - we use a non standard HTTPS port so the SERVER_HTTPS_PORT define should always be used in place of 443 $protocol = $_SERVER['SERVER_PORT'] == SERVER_HTTPS_PORT ? 'https' : 'http'; header( "HTTP/1.0 301 Moved Permanently" ); header( "Status: 301" ); /...

Preventing directory listing by redirecting?

I'm wanting to use .htaccess to prevent directory listing. I've got pages within /location/ but I don't have an index file. So Im wanting to redirect to /location/about.php for example. Is there a way to do this, without creating a index.html and redirecting requests to that? Thanks for the help! ...

Conditional Regular Expression - Separate characters from dashes in URL and test if first character set (string) is numeric

How would you create a regular expression that would parse the following url http://example.com/answers/38-my-example-question-on-regular-expression Specifically, "/answers/38-my-example-question-on-regular-expression" versus "/answers/category" If the regex finds "38" a number, then it does this: RewriteRule answers/([-_~*a-zA-Z0-9]...

Is my htaccess file causing multiple calls to one page?

Hello all, I think my htaccess file that makes use of mod_rewrite is causing my pages to be called more than once. Can anyone see if this could happen with my current htaccess file? Or if there is even a possibility? This happens in the view.php page only (from what I have seen). # REWRITE DEFAULTS RewriteEngine On RewriteBase / Rewri...

htaccess rewrite for query string

Ok, im pretty new at this and I would really appreciate some help, thanks! How can i rewrite this in .htaccess correctly? So I have a query string in my url: /?url=contact All i want to do is remove the query string /contact Help? I scoured google and I'm learning the syntax right now, but the fact remains..I dont know how to do i...

How can I make wordpress stop permalinking non wp directories?

How can i make my WP install stop taking over directories that it has nothing to do with? I have a directory thats password protected via ht access and when it wasnt protected, i could access it, but now that it is, it throws me a WP 404 page. this is the existing wp htaccess file # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngi...

Can I do an if/then/else in htaccess?

I have a site that serves up certain content based on the subdomain. So it is the same set of files, and maybe the header and some info in the site pages changes based on the subdomain. I need to have different htpassword authentication based on the subdomain as well, but can't find info on how to do an if/then type of thing in htacces...

Date and name based friendly URL using .htaccess

Hi, I'm planning on switching from having my blog on wordpress.com to having it on my own site hosted on my own server. Naturally I want to preserve the link structure from wordpress so that no links to my blog out there on the WWW break. So my question is, how do I get the following friendly URL http://example.com/yyyy/mm/dd/post-nam...

htaccess mask dynamic url with a static url

I'm trying to do something with .htaccess that I'm not sure can be done. First thing I did is hide the .php extensions using the following code: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php Works great. Now what I'm trying to do and can't seem to figure out is...

.htaccess rewriting url to page or directory

For my site I have a RewriteRule that points the URL http://www.mysite.com/work to a work.php file. I also have a directory called "work" that has files in it, like project1.php, project2.php, etc... What rules would I have to write so that the URL http://www.mysite.com/work knows to go to the work.php file, but the URL http://www.mysit...

htaccess redirect problems

My .htaccess looks like this: RewriteEngine on RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)|(\.swf)|(\.xpi)|(\.ico)|(\.src)$ RewriteCond %{REQUEST_URI} ^(.*)$ #RewriteCond %{REQUEST_FILENAME} ! -f RewriteRule (.*)$ view.php?picid=$1 [L] Problem is that when I visit www.example.com, it’s sending me to v...

control downloading (.htaccess?)

I need to protect a .zip file from being downloaded w/o permission. I would like to be able to provide a direct link to the .zip download to those who have access to the files. <filesmatch .zip> order deny, allow deny from all </filesmatch> does not seem to work. It prevents direct links, but I am not sure how to provide the downlo...

htaccess redirect for subdomains -> similarly-named subdirectories?

I'm restructuring a web site with a great deal of content currently parked at URLs that look like this. http://string.domain.com/year/month/dd/string-pulled-from-title For various reasons, I'd like to park all new content at URLs that looks like this http://www.domain.com/blogs/string/year/month/dd/string-pulled-from-title I'd like t...

Allow/deny image hotlinking with .htaccess

So I've got this in my site .htaccess file to prevent hotlinking of images, JS and CSS from all other domains. RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.com [NC] RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L] Question: How would I selectively allow one or two domains to hotlink? ...

How can I make my .htaccess file allow Safari & other browsers to open GZIP?

I'm using an .htaccess file to allow my pages to call gzipped JavaScript files. It works fine in ie8 & ff3, but the script is not loaded in Safari (or Chrome). Here is the .htaccess file I'm using: <files *.js.gz> ForceType text/javascript Header set Content-Encoding: gzip </files> Then, for example, I can call JS files from my HTML...

Apache mod rewrite returns blank screen for php files with wordpress header included

Here's simplified .htaccess file: RewriteEngine On RewriteRule ^index$ index.php On my local lamp server everything works fine, but there are some problems on production server. myurl/index returns only blank screen, php is not parsed. When required file is accessed directly (myurl/index.php) it works fine. I noticed that this prob...