.htaccess

How can I set up htacces and mod_rewrite to use a domain wildcard?

The following forces non-www domains and sends https requests to http and is working fine for example.com. How can I use a wildcard for the domain? RewriteCond %{HTTP_HOST} !^example\.com$ RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$ RewriteRule (.*) http%2://example.com/$1 [R=301,L] I have two domains, example.com and example2.co...

rewrite language extension in URLs with htaccess

Hi, ` I'm having some troubles with url rewrites in htaccess. I have all my PHP pages in subfolder /pages. These are my urls: http://www.example/tickets http://www.example/en/tickets http://www.example/fr/tickets http://www.example/nl/tickets --> all these should point to /pages/tickets.php Currently I use this in htaccess: Rewrite...

Regex pattern help (I almost have it, just need a bit of expertise to finish it)

I need to match two cases js/example_directory/example_name.js and js/example_directory/example_name.js?12345 (where 12345 is a digit string of unknown length and the directory can be limitless in depth or not exist at all) I need to capture in both cases everything between js/ and .js and if ? exists capture the digit stri...

Apache server-side files caching via .htaccess?

Hi, I'm starting new website and gonna include several JS libs and would like to know how .htaccess file template should look like with caching of media and JS files on? Whats better for compression, GZip or Deflate? Is it better/faster solution to serve those JS libs off the Google CDN perhaps then locally? I'm asking CDN question s...

.htaccess template

I made an .htaccess template; is there anything else that should be added or changed? # DEFAULTS ServerSignature Off AddDefaultCharset UTF-8 DefaultLanguage en-US SetEnv Europe/Belgrade SetEnv SERVER_ADMIN [email protected] # Rewrites RewriteEngine On RewriteBase / # Redirect to WWW RewriteCond %{HTTP_HOST} ^serpentineseo.com Rewrit...

How secure is .htaccess protected pages

Are there any known flaws with htaccess protected pages? I know they are acceptable to brute force attacks as there is no limit to the amount of times someone can attempt to login. And a user can uploaded and execute a file on the server all bets are off... Anything other .htaccess flaws? ...

Website files caching?

I want to know how long certain files like css, html and js are desirable to be cached by .htaccess setting and why different time setting for each file type? In few examples i saw that someone cache html for 10 mins, js for a month and imagery for a year. ...

.htaccess help: changing /register.php into /register

I have no idea about anything to do with .htaccess, apart from the basics of what it's used for. In this case I need it to rewrite URLs. I have a set of pages: index.php register.php login.php donate.php And I wanted to change them into URL's like this: http://localhost/ http://localhost/register http://localhost/login http://localh...

htaccess/htpasswd in hierarchical folder structure

I have a folder (folder_1) that is protected by htaccess/htpasswd files. Inside that folder is another folder (folder_2) that is protected by another couple of htaccess/htpasswd files. When a php-script in folder_1 or folder_2 is called, the user has to authenticate herself using the correct username and password as specified in the res...

htacces redirection if the url doesn't have .php extension

I wish to redirect all page requests if (1) Current URL doesn't have .php extension (2) Current Page is not the Site Home (ie www.site.com ) Example: http://site.com/robin to profile.php?screen_name=robin Can someone suggests the htaccess to accomplish this? ...

.htaccess ModREwrite

This is a totally new area for me so please be patient. I want to create "permalinks" for a dynamic site I am working on. At the moment all the pages (not the index) are referenced using an ID variable thus: http://www.domainname.com/page.php?ID=122 (etc) I want to create a suitable rewrite rule so that a useable URL would be more l...

.htaccess query string with static page

So, unfortunately I'm using vBulletin with Kohana and my integration is getting a bit complicated locking vBulletin out. Doing some rewrites, this in particular: RewriteCond %{QUERY_STRING} ^do=(editprofile|editoptions)$ RewriteRule ^forum/profile.php$ /user_profile/edit/ [R=301,L] Comes back with /user_profile/edit/?do=editprofile ...

How to determine MIME Type set by htaccess in PHP

I have a .htaccess file set up to define specific MIME types in directory root/a/b/, and all of the files are in the same directory. I have a php file that wants to serve those files, in directory root/c/, and needs to determine the content-type as defined by the .htaccess file. Is there any way to do this? PHP version is 5.1.6. mime...

Multiple domains on apache server

First a quick disclaimer, I'm not a 'server guy' or a 'unix pro' or anything like that, I'm a web programmer who got stuck doing server works since I ran linux (ubuntu) on my netbook. I'm trying to set up an apache server running on Debian to automagically serve multiple domains, each domain needs to have its own directory in /var/www. ...

Remove part of the URL with .htaccess

Hello. I've changed some settings in my website, and now I need to redirect from: www.plugb.com/home/game/a www.plugb.com/home/something/else www.plugb.com/home/game/b ... to www.plugb.com/game/a www.plugb.com/something/else www.plugb.com/game/b ... I don't know how to do this with .htaccess. BTW, I'm using CodeIgniter. Thanks in...

Using .htaccess redirect a site root to a site subfolder

Hi, I want to be able to redirect my visitors from http://www.example.com and http://example.com to http://example.com/blog. How can I do that, I saw some examples but any of them works for me. Thanks. ...

301 All aspx files to a Subdomain

We just redesigned a site for a client in EE, located at example.com (with and without www.). Their original site is ASPX. They've still got a number of ASPX pages that they want to keep, so their IT people created a subdomain, www2, which is basically a clone of their old site. I need an htaccess rule that will check if the requested...

Use Mod_Rewrite to Rewrite ROOT to Another Path

Note: I have tried the suggestions under this question but they either don't work or give me an infinite redirect loop error. I have the following in my .htaccess file: <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase / # Rewrite old links to new Redirect 301 /howitworks.php /ho...

Gateway page system

I'm trying to alter the way we currently provide a gateway page system within our CMS. What i mean by gateway page is mapping a non-existent URL to a page through a rewrite rule in the .htaccess, e.g. RewriteRule ^foobar$ page.php?mode=bar&method=foo&id=1 This allows people to create short links to CMS pages for magazine adverts etc. ...

Create fake subdirectories with htaccess and php AND keep existing directories as is.

I have a website, which has numerous subdirectories already. (All existing in server's filesystem) I want to create new "virtual" sub-dirs with htaccess, but I only want the htaccess rule work for directories, listed in DB, and not existing in filesystem. i.e. File system has: /dir1/ & /dir2/ MySQL database has record for 'dir3' & 'di...