mod-rewrite

Find the page that the user intended to see

I'm rebuilding a site with a lot of incoming links, and the URL structure is completely changing. I'm using the stock mod_rewrite solution to redirect all old links to new pages. However, as I'm sure a few links will slip through the net, I've built a small script that runs on my custom 404 page, to log the incoming visitors' referrer UR...

mod_rewrite Rule to Cover All Domains

Is there a way to have a RewriteRule fire on any domain that is requested on a box? For example, I have 5 VirtualHosts that would have the exact same RewriteRule applied to them and currently each VirtualHost directive has the rule, but can I put this somewhere 'global' so that upkeep is easier? ...

Are clean URLs a backend or a frontend thing

What do you think.. are clean URLs a backend or frontend 'discipline' ...

Best practices for getting cross-site JSON responses to POST?

I'm working on an intranet with several subdomains. I have control over each subdomain, so security of cross-site requests is not a concern. I have PHP scripts with JSON responses I'd like to call from multiple subdomains without duplication. For GET requests, I can do this with AJAX and JSONP, but that doesn't work with POST requests. S...

How do I get tomcat 5.5 to run behind apache 2 with mod_rewrite passing through requests to mod_jk and stripping app context?

Ok, so I want to get a webapp running in tomcat (5.5) to run behind apache 2 (2.2.3 to be precise) serving from the root of the site (i.e. without the context), with static content being served via apache. So if the app is running under "/myapp" on tomcat I want to use apache (plus mod_rewrite) to make it behave as if it's running under...

How do I troubleshoot why my rewrite rules aren't being applied by apache?

I've got a tomcat 6 web app running with apache httpd as the front end. I'm using mod_proxy and mod_proxy_ajp to forward the requests to tomcat. My server is running ubuntu. Now I'm trying to use mod_rewrite to remove the leading www, so that my canonical website url is http://domain.com rather than http://www.domain.com I've read a ...

Using Wild Card Subdomains With Mod Rewrite?

I have Wild Card Subdomains on, however I just do not know mod_rewrite to the extent that is required to write this. Can anyone tell me how to make it so anything other than www and nothing go to the main site but any subdomain other than that go to /script/index.php?username=$username? ...

Stop Mod_Rewrite execution on matching RewriteCond

I am running the free version of Helicon ISAPI Rewrite on IIS and have several sites running through the same set of rewrite rules. Up 'til now this has been fine as all the rules have applied to all the sites. I have recently added a new site which I don't want to run through all the rules. Is there any way to make requests to this site...

Apache MOD_REWRITE Domain Level Cookie

I need to deal with Affiliate Tracking on our website. In our .htaccess we have: RewriteCond %{QUERY_STRING} affiliate=(.*) RewriteRule ^(.*)$ $1? [NC,R,L,co=AFFID:%1:%{HTTP:Host}:7200:/] Which creates a COOKIE called AFFID with the value of the URL Parameter affiliate. But the Cookie is not for the whole domain, i.e. Going to http...

Do MOD_Rewrite rewrites invoke a second run through the rewrite rules?

When a RewriteRule is executed by MOD_Rewrite will all the MOD_Rewrite rules be executed again for the newly generated request? Specifically in the following example, will this cause a loop? RewriteCond Host: (?:www\.)?mysite\.com RewriteRule ^(.*)$ $1 [QSA,L] ...

How to configure mod_rewrite to serve minified files, if available?

Hi, mod_rewrite gurus! Here is the problem: we have lots of Javascripts and lots of CSS files, which we'd rather be serving minified. Minification is easy: set up the YUI Compressor, run an Ant task, and it spits out minified files, which we save beside the originals. So we end up with the following directory structure somewhere inside...

Escaping spaces in mod_rewrite

I have the following Apache mod_rewrite rule: RewriteRule ^(.*) http://127.0.0.1:4321/$1 [proxy] This works great; Apache forwards all requests to the CherryPy server I have running on the same machine. Unfortunately, I'm having some problems with paths which have a space. If I make a request for /Sites/some%20site/image.png then Ap...

How to verify that mod_rewrite is working

I am having a lot of trouble with mod_rewrite, and for a while I had it going, but for some reason everything has stopped working. Is there any sort of basic test that I can do to make sure that it is not something fundamental broken. It does show up in phpinfo(); ...

http to https to http using mod_rewrite and IBM http server

Ok I have an apache IBM HTTP Server WAS 6.1 setup I have my certs correctly installed and can successfully load http and https pages. After a successful j_security_check authentication via https I want the now authorized page (and all subsequent pages) to load as http I want this all to work with mod_rewrite because I don't want to c...

.htaccess require SSL for a particular URL

I want to force Apache to use HTTPS for a particular URL in the following form: https://www.example.com/signup/* so if someone goes to any of the following example URLs directly, Apache will forward the URL over to the HTTPS equivalent site. e.g. http://www.example.com/signup --> https://www.example.com/signup http://www.example....

Apache modrewrite .htaccess question

I want to be able to rewrite a URL from: // examples http://example.com/location/New York, NY --> http://example.com/location/index.html?location=New York, NY http://example.com/location/90210 --> http://example.com/location/index.html?location=90210 http://example.com/location/Texas --> http://example.com/location/index.html?locat...

Is mod_rewrite a valid option for caching dynamic pages with Apache?

I have read about a technique involving writing to disk a rendered dynamic page and using that when it exists using mod_rewrite. I was thinking about cleaning out the cached version every X minutes using a cron job. I was wondering if this was a viable option or if there were better alternatives that I am not aware of. (Note that I'm o...

mod_rewrite, php and the .htaccess file

I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem. I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be site.com/tools By my underst...

How to write a mod_rewrite rule to look for an image in a specific folder?

I need to write a rule to redirect any image file to a specific folder. Namely "images" RewriteCond $1 ^(.*\.jpg|.*\.gif|.*\.bmp) That will match all the imag, the the rerwrite part is confusing me. I want that Http://domain.com/path/controller/view/image.jpg http://domain.com/any/path/that/i/want/image.jpg to load the file http:...

UTF-8 URI explodes Apache & mod_rewrite

I have Apache with mod_rewrite, and whenever I enter a URI with an accented character in it, Apache gives me a "Page Not Found" error. The URI is: /places/tags/Café My page encoding is UTF-8. My database connection & tables are UTF-8. My Apache DefaultCharacterSet = UTF-8. Yes, Apache has language packs, but I believe they're there for...