.htaccess

How to hide certain file type using apache .htaccess?

Its been a long time since I've needed to crack open an .htaccess file... What is the simplest way to 40x prevent access to a specific file extension though out the entire site? ...

Redirect index.php in CodeIgniter

Hello. I created a CodeIgniter application and now I'm trying to redirect the urls with index.php to urls without it. My current .htaccess is: RewriteEngine On RewriteBase / # Removes trailing slashes (prevents SEO duplicate content issues) RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ $1 [L,R=301] # Enforce www # If you h...

htaccess to not show index.php in sub directory

I have a simple page structure like below /directory/subdir_1/index.php /directory/subdir_2/index.php .... (there are no other files in these directories) is it possible to have 'fake/pretty' urls for the above files as below? /directory/subdir_1 /directory/subdir_2 ... so this path would show whether the visitor typed that,/dir...

Any way to chunk gzip with Apache and PHP

I have a web application on a site that takes a while (~10 seconds) to complete a portion of the page near the bottom - it has been as optimized as it can be, and caching is not an option. We have compression enabled on the server via an .htaccess directive SetOutputFilter DEFLATE the problem is this causes the whole page to be held unt...

Can I use php's fwrite with 644 file permissions?

I am trying to set up automated .htaccess updating. This clearly needs to be as secure as possible, however right now the best I can do file permission-wise is 666. What can I do to setup either my server or php code so that my script's fwrite() command will work with 644 or better? For instance is there a way to set my script(s) to ...

What is .htaccess RewriteRule best practice?

Is it better to have a single RewriteRule with a bunch of RegEx or multiples Rules with fewer RegEx for the server to query? Will there be any performance differences? Heres is an example a single rule with almost all RegEx groups as optional: RewriteRule ^gallery/?([\w]+)?/?([\w]+)?/?([\d]+)?/?([\w]+)/?$ /gallery.php?$1=$2&start=$3&b...

Using htaccess redirect all files to another domain but exclude the root domain.

Recently, I want to restructure and redesign my website, my old website located at www.example.com, there are lots of blog posts under this domain, like: www.example.com/post1 www.example.com/post2 www.example.com/post3 ... I can redirect all those posts to another sub domain points in another folder (not sub folder), (if I put all th...

.htaccess why problem when using ? in Redirect.

i have this line Redirect /?page=cms_page&id=12 http://www.domain.dk/case when i type ?page=...... its not will work if i only use page=..... its will work fine but not the user type domain.dk/?page=cms_page&id=12 So now i ask you guys what have i make wrong? ...

What does this error states in php?

I have added htaccess file to my codeigniter folder and since then i get Server error! The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. If you think this is a server error, please contact the webmaster. Error ...

How to use htaccess to rewrite url to html anchor tag (#)

Hi - I have a situation where I want to take the following URL: /1/john and have it redirect using Apache's htaccess file to go to /page.php?id=1&name=john#john so that it goes to an html anchor with the name of john. I've found a lot of reference to escaping special characters, and to adding the [NE] flag so that the redirect ign...

Deny http access to a directory, allow access from WordPress plugin

Hey. I need to prevent direct access to http://www.site.com/wp-content/uploads/folder/something.pdf through the browser. However the Download Monitor plugin I am using, which allows logged in users to download the file, needs to be able to work. Trying Order Allow,Deny Deny from all Allow from all but the download links do not no...

How do I rewrite .php to .html using .htaccess rules?

I want to convert .php extension to .html extension using .htaccess rules Is this something I can do, and if so, how? ...

htaccess password protection and mod-rewrite?

hey guys, i wonder how i can solve the following problem. on the root directory of my server lies a file calles upload.php i want to be able to add a "/upload" (without .php) to my URL and the browser should ask for a password (and maybe username if possible). I i enter the password (and username) correctly upload.php should be opened. ...

Regex to allow all php files except one

Hi all, I have this regex that allow all php files : ^.*\.([Pp][Hh][Pp]) how can I exclude a specific file, for example test.php ? Thanks for your answer, Best regards [edit] I omit to say that it is a reg from a htaccess file, the /i doesn't seems to work, and the ? neither. [Edit2] the purpose is to grant access to authenticated...

.htaccess change displayed url

Hi, is there any way to get example.com/all-requests to go to example.com/forum/all-requests but still have the browser url show the former? (iow not just a simple forward call). Thanks! ...

Is there a better way to write this .htaccess directive?

I want all css, javascript, and image file requests, that are named like this "filename.12345.css" to be re-routed to "filename.css". The ".12345" part will always be numbers and the length can be anywhere from 11 - 15 characters. This directive seems to work OK but I want to make sure there is no error in my logic. RewriteRule ^(.+...

& symbol problem in htaccess

hello.... my current url is categories_name.php?cname=at&t rewritten url like this. carriers/at&t this is htaccess url. RewriteRule ^carriers/(.*)$ categories_name.php?cname=$1 [L] above url is working for all like categories_name.php?cname=all-tel when variable(at&t) has '&' symbol then problem occuring. so how to write hta...

need help in htaccess

I need my URL to be like this: http://example.com/index.php?title=about -> http://example.com/about/ The title more than 50, and same goes to pages. Any idea? Thanks ...

Rewrite url for missing resource

For each web request (file or directory) that doesn't start with /en-US/, I want to serve up the original resource if it exists, otherwise serve up the /en-US/ version. How would I do this using rewrite rules in a .htaccess file? ...

Redirect based on Accept-Language

I need to honor the web browser's list of language preferences. Supported languages are English and French. For example: http_accept_language="jp-JP;fr;en-US;en" redirects to a directory called /French/. How can I do this with rewrite rules in my .htaccess file? ...