.htaccess

Advanced Htaccess Rewrite Rule For PHP

I currently have the following code to rewrite search engine friendly url's to something PHP can handle however there are a few issues. Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*)/(.*) index.php?$1/$2 This Rewrites: domain.com/cat/mens/size/large/ To This: domain.com/index.php?cat/men...

running other file types as php

is there any problem with running html as php via htaccess? such as security or best practices ect. was doing this to make urls cleaner. ## run the following file types as php Addhandler application/x-httpd-php .html .htm .rss .xml well ideally id like to have my urls like localhost/blog/posts/view.php?id=64 to be localhost/projec...

Is there a way to return 404 Not Found for prohibited directory listings in Apache?

My web server is Apache. I have disabled directory listings via an Options -Indexes directive in a .htaccess file, so if a user navigates to a directory without an index.html file, he'll get a 403 Forbidden error. However, I'd like to return 404 Not Found in such instances instead. Is that possible? ...

How to write .htaccess if django project is in subfolder and subdomain?

The path to my django site is: staging.ninjawebsite.com/clients/project/ I want that to be treated as the base url. The django project is in the public_html/clients/project subfolder. Everything seems to be working fine but all links to say /city/ should go to staging.ninjawebsite.com/clients/project/city/ but it goes to staging.ninjaweb...

.htaccess & Wordpress: Exclude folder from RewriteRule

I have this .htaccess file in Wordpress. It's located at /public_html/ (web root). I need to exclude a folder (csNewsAd) from the rewrite engine. I've tried this, based from another question similar here at SO, but didn't work at all. AddHandler x-httpd-php5 .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ...

Simple htaccess redirect - subdomain to folder

I am trying to redirect http://[random-string].domain.com/ to http://domain.com/folder/[random-string]/ I currently have this: RewriteCond %{HTTP_HOST} ^.*\.domain\.com RewriteRule ^.*$ http://domain.com/folder/$1/ [R=301,L] It currently points to http://domain.com/folder//. (The $1 is missing) How do I fix this? ...

HTTP to HTTPS using mod_rewrite

Guys, I'm looking for a simple way to have this done. I would to have the .htaccess file rewrite to HTTPS if this is typed in the address bar: www.example.com example.com http://www.example.com I would like any of these potabilities redirect to https://www.example.com Thanks guys... I haven't found anything for this situation. Jus...

Another .htaccess Question about redirects

I want to redirect /forums/uploads/profile/photo-thumb-[RANDOMNUMBER].jpg to a static no photo file like: /forums/uploads/profile/photo-thumb-none.jpg I know it can be done with .htaccess I am currently experiencing lots of 404 Errors. Thanks ...

Apache .htaccess redirecting directory to querystring

i would like to redirect requests on my site from host.com/directory to host.com/?institution=directory so that users can access the main level categories of my site using a directory notation I just have a hard time wrapping my head around the regex, any help would be appreciated ...

Beginner Url Rewrite htaccess

I would simply like to rewrite all requests from: http://example.com/products/product.cfm?id=product-name to http://example.com/products/product-name and secondly, http://example.com/category.cfm?id=some-category&amp;sub=sub-category to http://example.com/some-category/sub-category Here is what I’ve tried: Options +FollowSym...

share a folder in 2 domains using .htaccess

Dear all, I got 2 sub-domains c:\wamp\www\websiteA\ - http://websiteA/ c:\wamp\www\websiteB\ - http://websiteB/ inside websiteA got a folder for storing picture c:\wamp\www\websiteA\photos\ in order websiteB want to access websiteA photo in websiteB's html I have to do link like url: http://websiteB/1.html <img src="http://we...

On password-protected site, how to whitelist certain referring domains?

I have a site that is password-protected using a .htaccess and .htpasswd file. I'd like for users to bypass the login prompt ONLY if they come from a certain domain. Can this be done by embedding the .htaccess credentials as parameters in the link somehow? Edit: I do manage the domain I'd like to whitelist, so how can I pass GET parame...

how do I override htaccess rule for a specific directory

Hello everyone, I have created following rule in the .htaccess file located at the root of my application as (like this, app_name/.htaccess ) Options +FollowSymLinks RewriteEngine on RewriteRule ^([^/]*)/([^/]*)$ /index.php?client=$1&page=$2 [L] The problem now is that I am not able to access the "captcha class" located in the class...

htaccess mod_rewrite how to rewrite empty vars

Hi Guys, I tried to create a htaccess file that rewrites, for example the URL from /index.php?type=car&model=audi&color=990000&year=1995 to /index/car/audi/990000/1995. At the moment i use the following: Options +FollowSymLinks RewriteEngine On RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+) $1.php?type=$2&model=$3&color=$4&year...

PHP cookie problem - www or without www

Why is it that if I create a cookie on www.example.com and check it on example.com, the cookie doesn't exist there? I am planning to just use .htaccess redirect non-www to a www domain. But how do I solve this? ...

Updating .htaccess rewrite conditions

I'll like to update the following rewrite condition to only allow one particular subdomain. RewriteCond %{HTTP_HOST} !^domain.com$ [NC] At the moment, it matches all subdomains, but I'd like to allow just one - admin.domain.com. How would I do this? Thanks for any help in advance. ...

Going mad with infinite loop and RewriteCond, need help.

I want to redirect users to my home page if they enter any URL not starting with 'en' or 'fr'. I've spent hours trying to make this work but this proves too tough for my fragile newbie brain. Currently, if I try to go to http://mysite.com/fr/produits/ Firefox tells me that the redirect will never complete. Here's what I want: http:/...

htacces to serve cached files

I have a file caching system for a php application. if a file needs cached i save it to a cache dir as flat html mimicking the directory structure of the request_uri how could i check with htaccess if there is a flat file in this cache dir before continuing as normal? currently i check with php, but ideally if there is a cached file, i ...

Adding slashes to the end of directories + more (htaccess)

This is beyond my level and I need some help. In the htaccess make redirect rules for the following... if example.com/1stleveldirectory doesn't end in a slash add one. if example.com/1stleveldirectory/ ends in a slash don't add anything. if example.com/1stleveldirectory/file is like this add .html. if example.com/1stleveldirectory/fil...

How does the .htaccess mod_rewrite for my Site: http://bit.ly/2Ocf3B looks like, to have SEO friendly urls?

I'm trying to optimize my site to make it SEO and user-friendly, I have several problems to set the right mod_rewrite for the urls and need help for this, I'm new to it, so it's way beyong my knowledge for the moment. http://bit.ly/2Ocf3B , the site should look like this: www.domain.me/category/subcategory . thanks ...