mod-rewrite

Why does a hyphen in a RewriteRule break when in a sub-folder

I have a bunch of RewriteRules in .htaccess for SEO purposes. Sample... RewriteEngine On RewriteRule ^signup$ /signup.php RewriteRule ^account$ /account.php RewriteRule ^logout$ /logout.php RewriteRule ^login$ /login.php RewriteRule ^recent-questions$ /recent.php RewriteRule ^popular-questions$ /popular.php ... ... (more similar stuff...

[Apache HTTPD] How do I serve some path patterns from DocumentRoot, and others from modjk?

We have an existing situation where we have Apache 2.0 HTTPD acting as the load balancer for a cluster of backend tomcats, using mod_jk 1.2 to communicate between the two. The applications themselves are stored on the tomcat servers, and so all requests are passed through (even images, css, etc) to tomcat, using the following in the virt...

Can I pass matched variables to the new URL with mod_rewrite?

I'm quite experienced in PHP but I don't quite use mod_rewrite (although I should). All I want to ask is if it's possible to pass many variables through a single rewrite rule. For example, is it possible to rewrite this: localhost/test.php?id=1&name=test&var1=3 into this: localhost/mysupertest/ and also use the same rewrite rule f...

htaccess code to remove extension AND add+force trailing slash?

I'm trying to put together some htaccess code that will turn example.com/filename.php into example.com/filename/ (and force the slash) - I've tried varous approaches, but each hasn't worked quite right, from 500 errors on subfolders to issues with the trailing slash, etc... Please help! ...

Get mod_rewrite to ignore directories and all subdirectories?

I'm using Symphony CMS which as default has a mod_rewrite that rewrites all directories. However, I need it to ignore the directories "test" and "transfer" and all their subdirectories. Any help? ...

redirect 301 question

Hi! We just switched to our new website redesign. We have a copy of the previous one in a folder "v1" and the new one is in "v2". I play with 2 .htaccess files. The file are organised as such: root L .htaccess (1) L v1 L v2 L .htaccess (2) .htaccess 1 does 2 things: remove the www out of the URI redirects all requests to v2/...

mod_rewrite based on ip

Hi, I'd like to implement mod_rewrite to put my site into maintance. Basically all ips except a handful we specify would be forwarded to a static html page. Please can someone help with this rule. Also is there a way to turn this on and off easily without editting the htaccess file? Thanks, Josh ...

Apache rewrite engine, get subdomain and path after it

I have the basic code to rewrite a subdomain to another page. But how do I use this to get the path of the directory specified within it and pass it to my script as well as the subdomain itself? Current code RewriteCond %{HTTP_HOST} ^([^.]+)(\.example\.com)$ RewriteRule ^$ handle.php [L] I'd like to provide handle.php with the file p...

adding a trailing slash for specific redirection rules

I'm moving a website to Wordpress and simultaneously changing the convoluted URL structure they had on their old platform. A typical URL looks something like this: /blog/index.php/weblog/comments/post-name But could also look like this: /blog/index.php/weblog/comments/post-name/ (not the inconsistent use of the trailing slash) This ...

Completely stumped with .htaccess

Hi All, I'm trying to write what I thought was a pretty simple rule but either I'm missing something painfully obvious or it isn't such a simple rule. In fact two others have looked at it and no one can seem to tell what I'm doing wrong. I just moved a site to a new platform and need to set up some 301 redirects from dynamic pages to s...

Can I re-write my URLs like this and is it a good idea?

Hello all, Is it possible to re-write (Apache Mod-Rewrite) a URL from this: http://www.example.com/view.php?t=h5k6 to this http://www.example.com/h5k6 The reason for this re-write is that the URL needs to be very short (a bit like a tiny URL service). Would that new URL still hit my view.php page? Would it be able to still make use o...

How can I use mod_rewrite to 301 redirect example.com to www.example.com?

I need to redirect any URLs without "www." to URLs with "www." for better search engine optimization. I read that this is possible with mod_rewrite and .htaccess files, but I do not know the right code to use. Can anyone help? ...

.htaccess conditional rewrite

Hi guys, I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache. Basically what I need is that the Apache would check if the requested file exists in a sub folder, case in which Apache would serve this existing file, or, if the file does not exist, Apache would load the index.php file. The folder structure...

Mod Rewrite Easy problem with Cookies

I'm trying to catch all the non-logged-in users who are trying to get to a directory (where my .htaccess is placed). If someone is not logged-in and try to access some page in this directory, it will be redirected to page "user/?login=222" A user is logged-in, when the Cookie "HDV-UL" starts with a 5 digit number. This is my .htaccess: ...

looking at various mod_rewrite solutions for iis 6

Hi I have inherited a iis system with predominately php-mysql sites. We are looking to put in a few sites (mod-x and wordpress) where we need mod_rewrite for our iis 6 on 2003 win server. I am quite keen to choose a solution where we can might be able to just port over the standard install of the above systems to a lamp box without chan...

How do I make a url forbidden in apache mod_rewrite, based on the query string?

How do I make the following url forbidden in apache; main/index.php?site=ing I have tried the following; RewriteRule ^main/index.php?site=ing - [F] but with no luck... ...

how to re-write my url with mod_rewrite on apache?

I purchased a domain: josecvega.com Whenever someone tries to access http://www.josecvega.com it forwards them to my web-server. I have turned ON the mask, so when you initially reach my web-server of IP, 68.42.56.13, it still shows http://www.josecvega.com, but when you click on a link that takes you to another location on my web serv...

404 Error: Mod_Rewrite not working

I managed to get some help from a previous question and I have the following in my .htaccess in my web root. # REWRITE DEFAULTS RewriteEngine On RewriteBase / # /view.php?t=h5k6 externally to /h5k6 RewriteCond %{THE_REQUEST} ^GET\ /view\.php RewriteCond %{QUERY_STRING} ^([^&]*&)*t=([^&]+)&?.*$ RewriteRule ^/view\.php$ /%2 [L,R=301] # ...

Isapi Rewrite - access query string pattern matches in RewriteRule

Hi, I'm using Isapi Rewrite 3 (mod rewrite clone for IIS) and trying to rewrite URLs based on the query string - and then pass on part of that query string in the rewrite. So if I enter a URL like this: /test/home.cfm?page=default&arbitraryExtraArg=123 I want that to be rewritten as: /test/index.cfm?page=home&arbitraryExtraArg=123 I ...

Subdirectory Rewrite | Include All Relative Stuff

I'm trying to hide actual sub-directory from url path using mod_rewrite. The folder actual name is members and i want users to use area instead. The code I'm using works but no images or relative stuff is loading. The rule is missing certain parameters. Can you point me in the right direction? RewriteEngine on RewriteRule ^area/$ /mem...