mod-rewrite

mod_rewrite creates 301 instead of transparent redirection if folder exists

Hello, i'm having a small problem here. I'm using a simple rule to redirect all requests to a script, excepts some folders with static content : RewriteEngine On RewriteCond $1 !^(templates|css|js|uploads)/(.*)$ RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] Most of the time, the redirection is good and transparent. But if the folder mat...

Passing and URL as parameter in mod-rewrite

Hi Folks! I'm trying to pass an URL as a parameter in mod-rewrite. I guess there is a problem in my Regex. This my .htaccess: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule **^go/((http:\/\/)+[A-Za-z0-9\-]+[\.A-Za-z])/?$** feedmini.php?url=$1 [L] </IfModule> the URL I want to pass looks like http://www.aaaa.com/aaa/?q=v but ...

Rewrite Problem - L(ast) not being respected?

So I'm working on a CSS/JS compressing system for a site, that has basically the following htaccess RewriteEngine On ... RewriteRule ^css/images/(.*)$ images/site/$1?%{QUERY_STRING} [L] RewriteRule ^css/([0-9a-fA-F]{32})$ assets.php?hash=$1 [L] RewriteCond %{HTTP_HOST} ^www.site.com [NC] RewriteRule ^(.*)$ http://site.com/$1 [L,R=301...

.htaccess on specific filetypes

Hi! I have some magic stuff in my htaccess. It works very well but I don't know how RewriteRule ^[^_+/]. index.php I think it says that all requests should go through index.php no matter which directory the visitor ask for. So far so good. However images, css files, js files etc should of course not be parsed in index.php. Can I ex...

.htaccess rewrite problem

Having a weird problem. I have two sites, first is www.example.com/folder/site1/, second is www.example.com/folder/site2/. The problem I have is that my .htaccess code is only working on site1, why? My .htaccess code looks like this: RewriteEngine On RewriteBase /folder/site1/ # Do not enable rewriting for files or directories that ...

redirecting old rewrite rule into a new one

Hello I have this rule on my .htaccess file RewriteRule ^business/(.*)/(.*)/(.*)$ ./businesspage.php?name=$1&place=$2&id=$3 I want to make it shorter for SEO purposes, so there would be only two parameters, $3 & $1. However, I want the old URLs indexed on google to redirect to the new ones. How do I do it? For example /business/na...

how do i get mod_rewrite to execute the RewriteRules if and only if there is no paramater q= in the url?

the below code works to deal with my url structures but i need the rules not to work if there is parameter q= in the url. i tried to set up a rewritecond (in the commented out line below) without success, please help! thanks :) Options +FollowSymlinks RewriteEngine on # RewriteCond %{QUERY_STRING} q!=(.*) RewriteRule ^FSD/([^/]+)/([^...

A mod_rewrite rule to map all paths to index.php

I have a script at www.mydomain.com/mydirectory/index.php. I want to map all requests to subdirectories of mydirectories to the script. For instance, www.mydomain.com/mydirectory/mypath/ should be rewritten to www.mydomain.com/mydirectory/index.php/mypath/ How can I accomplish this? Thanks. ...

htaccess - forcing trailing slash two directories deep.

My website structure has a root /index.php, some files as /directory/index.php and some as /directory/(filename).php I have the following .htaccess which removes the php extensions and the "index.php" for my URLs, and forces trailing slashes on the first level directories for SEO goodness: RewriteCond %{REQUEST_FILENAME} !-d RewriteCon...

URL structure causing incomplete page to be returned by PHP's file_get_contents()

I've been doing some scraping with PHP and getting some strange results on a particular domain. For example, when I download this page: http://pitchfork.com/reviews/tracks/ It works fine. However if I try to download this page: http://pitchfork.com/reviews/tracks/1/ It returns an incomplete page, even though the content is exactly th...

Multi Site Wordpress rewrite rules in Nginx

I'm trying to run a multi domain blog installation with Wordpress and Nginx. The last step is to configure some rewrite rules in .htaccess (apache only) for the webserver. How so I translate this into Nginx rewrite rules. RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] # uploaded files RewriteRule ^files/(.+) wp-include...

Hard redirect file.php to /file (when /file is already being transparently redirected to /file.php)

Am already transparently redirecting requests for /file to /file.php -- accessing /file shows /file.php. My .htaccess: RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z]+)/?$ $1.php [L] Would now like to do a hard redirect for /file.php to /file -- if I hit up /file.php, URL in the address bar must show /file. Tried the following b...

.htaccess RewriteRule non-www to www without explicity specifying domain

I'm trying to make a general rewrite rule to redirect all domain.com requests to www.domain.com. RewriteCond %{HTTP_HOST} ^([0-9a-z-]+)\.([0-9a-z-]+])$ [NC] RewriteRule ^(.*)$ http://www.{HTTP_HOST}/$1 [R=301,L] The problem is that this rewrite rule doesn't match anything. How can I change it? Thanks ...

Dynamic subdomains + defined subdomains via htaccess

I hate asking questions about mod_rewrite, but I can't seem to get these rules working properly. I had it setup and figured out once before, but a few years have passed and now it's just not playing nice and my mod_rewrite knowledge is back to uhhhh...... Essentially what I want to do is force www on the main domain, example.com. (or f...

Getting id from pretty url as an intval

Alright, I have my urls set up to rewrite "news_item.php?id=1" to "blog/1/Title-of-post". This works great apart from when a title has numbers at the start for example "blog/23/12-days-to-go" it can't find the right id. Here's how I have it setup, maybe someone can make sense of it. Rewrite rules RewriteRule ^blog/([0-9]+)/([a-z-]+)/...

Edit RewriteRule to allow title in URL's

I have real trouble understanding mod_rewrite, and got some help in creating a RewriteRule to have simple urls for our site RewriteRule ^news/([a-zA-Z0-9_-]+)$ /news/$1/ [R] RewriteRule ^news/([a-zA-Z0-9_-]+)/$ news/show.php?id=$1 So someone can visit site.com/news/700/ and the url will look the same to them, but puts the request to o...

URL Rewriting on Localhost? Apache PHP

Hi, I am using Apache mod_rewrite on Xampp on my local machine but the code doesnt seem to work. Please look at the code below and assist me. I'm a beginner with this. RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^m3/([a-zA-Z0-9-]+)$/?profile=com...

replace host in htaccess

Hello! I am creating a website which is located in /shop/ on my webserver. It has a seperate domain. Now, I want to change every request that comes in. http://techinf.de/shop/ shall become http://holzwerkstatt-osel.de/ and http://www.techinf.de/shop/ shall become http://www.holzwerkstatt-osel.de/ the actual request, like product.php?...

.htaccess redirect prob.......

I created a site in 2 languages english (en) and arabic (ar). Whenever a visitor comes to mysite.com (index) he chooses a language and he will be either directed to ar.mysite.com or en.mysite.com ...the problem and you already know it, don't you? is that he is redirected to mysite.com/en/index.php instead of en.mysite.... and the same st...

Redirect "mydomain.com/user" to "mydomain.com/name.php?id=user"

I think I can use the .htaccess file for this, but I've looked it up and not found anything useful. What I want to do is have my site redirect to a php page when a user types their username in the URL like: example.com/username And have it be the same as a PHP page like: example.com/name.php?id=username I'd like it to display as ex...