mod-rewrite

Apache redirects (<whatever>.mydomain.<whatever> to mydomain.com)

In a virtual host in apache I would like to redirect all requests to <anything>.mydomain.<anything> to just mydomain.com. However, the below rewrite rule is ignored for some reason. Why? RewriteCond %{REMOTE_HOST} ^.*mydomain.* RewriteRule ^(.*)$ http://mydomain.com [R=301,L] ...

Remove all query strings from requests for particular page.

I have a flex application that for some reason I do not know why, when you are using google chrome and access the page with any query strings in the URL the applications behaves unexpectedly. The page does not need query strings though. But many things like adwords etc are passing variables in query strings for tracking purposes. But f...

Apache mod rewrites giving 404 error

Hi, I'm trying to set up a simple rewrite rule to convert a url such as: "index.php?page=login" to something like "page/login" However, I keep getting 404 errors. Can anyone suggest why the following might not be working? .htaccess: RewriteEngine on RewriteRule ^page/([^/\.]+)/?$ index.php?page=$1 [L] rewriteEngine off I'm qui...

Use htaccess to redirect all traffic from root to specific subdomain page

I have a site that has been up for some time. I had a blog on a subdomain for some time. I have decided to do away with the main site and just support the blog subdomain. I have a redirect setup for this, but it carries all the extra parameters through to the blog which results in a file not found page appearing. I just want the redi...

.HTACCESS File causing Internal Server Error

I have copied the files and database from BradPPresents.com to BradP.com. The .htaccess file is required to get pages to display properly since "Pretty URLs" are enabled by joomla!. You can see that the database and all connections are working at http://bradp.com/index.php, however http://bradp.com/home.html does not work as it relies...

mod_rewrite question

I would like to serve /foo and /foo/ locally, but proxy requests for /foo/* to a remote server. However, the following rule matches all of the above. What am I doing wrong? RewriteRule ^/foo/(.+)$ http://remote.host/$1 [P,L] ...

Problem redirecting 403 Forbidden to 404 Not Found.

The pertinent part of my .htaccess looks like this: Options -Indexes <FilesMatch include> Order allow,deny Deny from all </FilesMatch> RedirectMatch 404 ^/include(/.*)$ And it's generating the following responses: /include 403 /include/ 404 /include/config.inc 403 I can tell by looking at my pattern that problem is l...

mod_rewrite and CSS

I'm using mod_rewrite to change all the URLs on a site. Example: http://www.site.com/about/ becomes http://www.site.com/?action=about (don't worry, I have nice friendly sanity checking). The problem is that for anything other than http://www.site.com/ the CSS stylesheet won't load. I assume this is because it looks for the stylesheet in ...

Another mod_rewrite trailing slash question

I have the following rewrite rules in my .htaccess file: RewriteEngine on RewriteRule ^news/([0-9]+)/?$ /?action=news&start=$1 [L] RewriteRule ^man/([a-zA-Z0-9_]+)/?$ /?action=man&page=$1 [L] RewriteRule ^([a-zA-Z0-9_]+)/?$ /?action=$1 [L] All of then end with a /? to check for an optional trailing slash. This works - it means I can u...

Apache mod_rewrite and PHP ?argument=something

I'm trying to get all HTML and PHP files on my site to redirect through the index.php, so that they can have common frames applied to them, a templating solution I coded that I found to be quite elegant. Anywho, I'm having issues with my PHP files, specifically those that have arguments after them. My regular rule for PHP files is the f...

PHP Rewrite Rules

The actually URL which my app uses is: http://site.com/search.php?search=iPhone but I would like it to be possible to achieve the same with http://site.com/iPhone I have no experience of rewrite rules, how can I set this up? The solution has worked but the new URL is displayed in the address bar. I thought it would have been poss...

mod_rewrite help

Im trying to set up a simple rewrite rule but I dont seem to be able to get it to work. Basically I want to route any address that starts with "restaurants" to a certain place and all other addresses to my bootstrap. RewriteRule ^/restaurants http://www.google.com RewriteRule !^/restaurants index.php is what I have so far. ie. mysite...

Mod Rewrite: apply to all js and css files except ...

Hi I need to apply a minify actions to all the javascript and CSS files, except the ones I indicate. I have this condition and rule that applies to all the files (css and js): RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*\.)(js|css)$ minify.php?q=$1$2 [L,NC] I need to add the conditions to say: Apply to all except: jquery.js,...

Is PHP allowed to modify .htaccess file in current folder?

I have a PHP web app located on shared hosting. My goal is to modify .htaccess file from PHP code when the PHP page is running. I need that .htaccess to insert a couple of mod_rewrite lines into it. The problem is that on Windows+Apache I can dinamically modify .htaccess file but the same code on Linux reports a problem when I try to ac...

Force https for entire server/domain

I am developing a number of forms which should only be accessed via https. I have a dedicated server with its own cert and all the good stuff. So my question is two-fold really: 1). What's the best way to force every request to be https? Is there a better way than this .htacess/mod_rewrite rule: RewriteCond %{HTTPS} off RewriteRule (....

RewriteRule - a.php?a=123 to /b/123

I am trying to get Apache to redirect /a.php?a=123 to /b/123 (where 123 could be any number between 1 and 9999) but can't seem to get it to work. This is what I have in htaccess: RewriteEngine on RewriteRule ^a.php?a=([0-9]+) /b/$1 [L] RewriteRule ^a.php$ /c/ [L] With this going to a.php?a=123 results in 404, but going to just a.php...

mod_rewrite - old parameter name to new name

Hi all I need a bit of getting a redirect working in mod_rewrite. I need to redirect the following http://mysite.com/dictionary/find?word=test to http://mysite.com/dictionary/find?w=test I'm sure the solution is trivial enough but my knowledge of mod_rewrite and regular expressions is quite limited and I haven't been able to work ...

Forcing SSL & www subdomain for any URI entered with .htaccess?

I have an SSL certificate for the 'www' subdomain of a web site we'll call example.com. Therefore I can force SSL, but if the user doesn't enter 'www.example.com' into their browser, the SSL certificate appears invalid. I wish to accomplish this with mod_rewrite rules in an .htaccess file at the root of the web site. No matter what UR...

URL Rewrite with Joomla on IIS7

I have Joomla 1.5.9 running on IIS7. I'm now experimenting with the SEO Settings from the Joomla global configuration page. First I toyed with Search Engine Friendly URLs (that gets rid of the queries part of URLs); that works fine. I also tried to enable the "Use Apache mod_rewrite". I installed "Microsoft URL Rewrite Module for IIS 7...

editing .htaccess file

I'm made a codeigniter app and I tried to use the apache mod_rewrite rules as RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] The problem is that I have this app in a folder abc/ but when I type mysite/abc/something (which should point to mysite/abc/index.php/somethin...