mod-rewrite

map .html to .php only is file exists

Here is my rule: RewriteRule ^(.*)\.html$ /$1.php This works for "virtual" .html urls which have a matching physical .php file on the server. However when I type in a url for an actual .html file, I cannot access it, because of course the rule above is telling the server to look for a physical .php file. So how can the rule be modif...

Mod Rewrite for NGINX

Hi Everyone, I'm currently using nginx as a transparent proxy for apache. I would like to use nginx + fcgi(php) but need mod-rewrite support. Is this possible or is there an alternative solution to my woes? This is for only 1 site, would litespeed be an effective solution? ...

Give 404 on existing folder/directory

I have a folder in my root that i want no one to know of. Even if someone types in it correct i want to throw a 404 not found. Would this be Possible to do with mod-rewrite perhaps? I cant store it outside root right now, dont ask why Thanks! ...

Pretty Profile URLs without conflicts with pages

Hello, I want to use profile URLs on my site such as xyz.com/username I am using the follow code: RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?p=profile&u=$1 [L,QSA] RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?p=profile&u=$1 [L,QSA] My question is... How can I use it like this, and keep the access to other links such as xyz.com/forums,...

HTAccess Page Redirecting problem with & sign

hi, I am trying to make my pages seo friendly. I have a links in my page. http://abc.com/test.php?Section=pages&title=feedback+%26+enquiry it works fine and title has value "feedback & enquiry". I changed above link to: http://abc.com/pages/feedback+%26+enquiry.htm I wrote the htaccess code like: Options +FollowSymLinks Rew...

mod_rewrite: serve images form another server

Hi, how can i write a mod_rewrite rule to handle all the requests like http://mysite.example/images/IMAGE.gif|jpg|png and serve instead http://mystaticfiles.example/IMAGE.gif|jpg|png ? Thanks ...

Adjusting dynamically generated links using .htaccess or any other method?

I have an e-commerce website (created with a ecommercetemplates shopping cart PHP template) and on the catalogue pages there are, at times, a few pages which are numbered at the bottom. The links to these pages are, for example, in the form:- /product.php?cat=27&pg=2 despite the main page having been mapped to:- /widgets using a rewrite...

.htaccess seems to be ignoring RewriteCond

Hi, This is the htaccess I have: Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} !^/pages RewriteRule ^(.+)/$ /$1 [NC] RewriteRule ^$ /pages/index.php [NC] RewriteRule ^([a-z]+)\?([^/]+)$ /pages/$1.php?$2 [NC] RewriteRule ^([a-z]+)/([^/]+)$ /pages/$1.php?q=$2 [NC] RewriteRule ^([a-z]+)$ /pages/$1.php [NC] ErrorDocum...

conditional statement for redirecting IPs using .htaccess?

Hey guys, I am hosting my own server and have two ip addresses for it (one for people connecting from within intranet and one for people connecting from outside) and I have two dynamic dns's redirecting to these ip's. I have just installed/setup SSL on my apache2-based server, and am trying to use .htaccess to force users to use https. I...

ISAPI Rewrite not redirecting request with query string

Hello all, I have installed the full verison of isapi_rewrite and have setup a proxy directive so that all traffic to my workstation in the folder 'ngis' (on any port) goes to another server. This is for testing purposes to check suitability before rolling out isapi_redirect to our prod servers. I have a rule as follows: RewriteRule ^...

Help me with a rewrite rule

I need help with some rewrite rule Pretty much all my pages look like this: index.php?key=guild&id=939&view=board index.php?key=player&id=300941&view=edit index.php?key=mod&id=41&view=download Would i be possible to use 1 rewrite rule? Since all my pages have same $_get's /guild/939/board /player/300941/edit ...

Problem with htaccess and mod_rewrite on new server

My htaccess file is a bit complex but it used to work on my old host and it works on my local machine. I transferring to ipage.com and none the rewrite rules works, For example : RewriteRule ^([\w]+)$ /index.php?module=view&id=$1 [L] used to make this url /asd display /index.php?module=view&id=asd i already spoke with a rep and all ...

how to redirect FIRST and then rewrite using mod_rewrite

Hi, I have two domains pointing to the same host, say example1.com and example2.com. I already have a redirect: RewriteRule ^([A-Za-z0-9-]+)/$ page.php?q=$1 [L] to catch things like example1.com/hello-world/ => example.com/page.php?q=hello-world Now I need 3 specific conditions to be met: 1) example1.com/special/ => example2.com/sp...

Re-direct problem with HTACCESS edit

Hi, RewriteEngine On RewriteCond %{HTTP_HOST} ^tsgcs\.ca$ RewriteRule (.*) http://www.tsgcs.ca/$1 [R=301,L] This is giving me errors 'Firefox has detected that the server is redirecting the request for this address in a way that will never complete.' Any ideas why? ...

Match "full stop" in mod rewrite

At the moment I am just matching numbers, letters, dashes and underscores in my .htaccess file: RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?folder=$1 I also want to match full stops in the string. I don't want to use: (.*) I have tried: ([.A-Za-z0-9-_]+) ([\.A-Za-z0-9-_]+) ([\\.A-Za-z0-9-_]+) ([A-Za-z0-9-_\.]+) None of which seem...

always preserve URL when redirecting to subfolder

I want to redirect all requests to a certain path on my server (/app) to a subdirectory at /app/app_site. Following rewrite rules do the job for requests like 'http://localhost/app/somepage.htm': RewriteCond %{REQUEST_URI} !^/app/app_site.*$ RewriteCond %{REQUEST_URI} !^/app_site.*$ RewriteRule ^/app(.*) /app/app_site$1 [L,PT] Thi...

Help with htaccess and two Wordpress instances.

I have an old legacy application, written in php. It's going to be replaced by two Wordpress instances, one being the website itself and the other being a blog (I have to use them separated as two instances). So I'm going to have a dir for this old version, a dir for the site and a dir for the blog. This is my situation now: Suppose my...

Using PHP script to assist .htaccess mod_rewrite

I'm planning to use large amounts of URL rewrites on my website, but I can't get familiar with Apache's mod_rewrite because it's difficult and poorly documented. I heard there's some option that allows invoking various scripts for the rewriting purpose. Can you help me with it? ...

Problem with mod_rewrite

Hello all, I have a problem with getting my .htaccess to work like I want and I was wondering if anyone could shed a light on this. Here is my current setup: My shared hosting site can be accessed by http://www20.a2hosting.com/~myname/ I have several sub directories inside that I wish to access. For instance http://www20.a2hosting....

.htaccess redirect only if ip address is not listed or not a specific url

I'm trying to setup a staging subdomain and only want to allow access to certain ip addresses, but allow everyone access to any url starting /api. What I have below works for the ip address, but always redirects if I try and access for example /api/projects or /api/users with an ip address not listed. Any help would be greatly apprecia...