mod-rewrite

Apache mod_rewrite only if request does not start with '/THEMES/'

Hi all SO users! I'm writing a CMS in PHP, and now I'm working at the themes feature. I have a .htaccess file: RewriteEngine ON RewriteRule ^([a-zA-Z][a-zA-Z0-9]*)$ index.php?m=$1 RewriteRule ^([a-zA-Z][a-zA-Z0-9]*)/(.+)$ index.php?m=$1&p=$2 If I have a request to: /page it must load the view function of the class called page. If...

.htaccess to hide CSS/JS version

Hello, I was wondering if it's at all possible to run a RewriteRule that will hide a CSS version in a link tag. Ex. link href="css/global.css?v=1.2.3" rel="stylesheet" type="text/css" To show up as Ex. link href="css/global.css" rel="stylesheet" type="text/css" I can't seem to find anything on this subject and everything I've attempt...

Mod_Rewrite Force HTTP On All Files Except One

Hi, Sorry if this has been asked before, but I couldn't find it. I have a folder which when I visit loads in both HTTPS and HTTP. I want all the files in that folder to load in HTTP except for one file. The file I need in in HTTPS is: login.php and this folder is called "forum". Also if it helps: All the files in the folder are *.php. ...

htaccess rule conflict?

In my .htaccess file I have the following rule defined. RewriteRule t/([^.]+)/$ /video/tag.php?tag=$1 [QSA] This rule is working fine for tag pages. When I am accessing URL as http://example.com/video/t/funny/ then its displaying all the result with tag funny. But When I am accessing a URL http://example.com/video/script/common/vide...

How to rewrite URL based on domain in apache and add extra parameter?

Hi, Basically, what I want to do is to rewrite all urls because we have many different languages. We have a server that hosts several domains. We have www.example.com, www.example.fr, www.example.de, www.anotherdomain.com, www.anotherdomain.de. What I want to do is to redirect all requests from example.xxx to www.example.com with extra u...

Setting up Wildcard subdomain (with reverse proxy) on apache 2.2.3

Hey All, What I am trying to achieve is the following: I want to have numerous subdomains such as abc.domain.com redirect to a url such as www.domain.com/something?subdomain=abc Since I am redirecting to a fully qualified domain, I needed to use a reverse proxy to avoid the change of the URL in the browser. (using the [P] Flag and turn...

Modrewrite and PHP issues

I am trying to write this rewrite code and it just is not working (apache 2.2): RewriteEngine on RewriteBase / RewriteRule ^account/activate\?token=(.*) index.php?route=account/activate&token=$1 I tried many different variations. After trying for about and hour and searching google I am stumped. This is where you come in! ...

Redirect 404 to another domain with apache?

Hey guys, have a question regarding apache. I have a site that's been re-engineered, but I want to capture all the 'old' links that people may have bookmarked or come from search engines to the old site which is under a new domain name. How do I get apache to redirect only 404 not found to the old site? TIA, J ...

How to use mod_rewrite to change external incoming images to local images?

Hi, I'm trying to figure out how to use mod_rewrite so that I can replace linked images (coming in externally) and use local ones instead. Why am I doing this? I have a plugin which I'm integrating into my site, which uses ugly external images as buttons, and I want to redo these buttons to match my site. The links come in external...

.htaccess URL reroute to different folder based on first part of query

Here is my .htaccess now rewriteengine on rewritecond %{HTTP_HOST} ^www.example.com$ [OR] rewritecond %{HTTP_HOST} ^example.com$ rewriterule ^index.php/? "http\:\/\/example\.com\/" [R=301,L] #4a397bb852bc9 Which sends all requests from the root directory to index.php What I need to do is send all requests from www.example.com/site2/ t...

Changing site URL with mod_rewrite

I'm finding a lot about creating pretty URIs and whatnot using mod_rewrite but what I'm looking for is a way to remove elements of a URL (as far as the viewer is concerned) and not just moving stuff around and/or reorganizing. I need this: http://www.mysite.com/foo/bar to be this: http://www.mysite.com/bar Basically, let's get rid o...

Modrewrite allow numbers, letters, underscore

I want to have a url that will allow for a tag to have underscores, numbers, and letters of any combination (uppercase or lowercase). Example: tags/WhaTever_eyE_D3sire RewriteRule ^tags/([A-Za-z0-9]+)$ tags/$1/ [R,QSA] RewriteRule ^tags/([A-Za-z0-9]+)/$ index.php?state=tags&tag=$1 [L,QSA] That is what I have right now. Can someone p...

Cannot able use Multiple rule in mod_rewrie

I need used use it RewriteEngine On RewriteCond %{SERVER_PORT} !^9090$ RewriteRule ^vendor/([0-9]+).html$ productcategory.iface?Operation=category&catid=$1 [L,R] RewriteRule ^vendor/([0-9]+)([0-9]+).html$ productcategory.iface?Operation=product&prodid=$2 RewriteRule ^vendor/([0-9]+)([0-9]+)([0-9]+).html$ productcategory.iface?Ope...

Weird .htaccess url rewrite discrepancy.

So http://myopicvoid.org/ when loaded in Firefox or Chrome, automatically redirects to http://myopicvoid.org/main as well it should, but not in IE8. What exactly would cause this? My .htaccess is as follows: Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^myopicvoid\.org$ RewriteCond %{REQUEST_URI} ^/$ RewriteRule /...

mod_rewrite to get query string PHP

I asked a question a while ago to sort out my directory structure and you all solved my problem (Thanks!) but im now changing this site to another server and rewrite rule does not work. I cannot find the problem. I sent a support ticked to the hosting and they said: If that statement doesnt work then it will be either incorrect, or n...

How do I make .htaccess work on the current directory and not subdirectories?

I'm using mod rewrite to access my PHP files in the root directory of my website indirectly. Currently, I have something like this, RewriteRule ^(blog|about|page3|etc)$ /$1.php [L] But what I would like to use is RewriteRule ^(.*)$ /$1.php [L] So that I wouldn't have to update my .htaccess file whenever I wanna add a new page to my...

Wordpress mod_rewrite is stopping my query string from working!

In my root .htaccess file wordpress has put this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress and in a sub directory I have a .htaccess file that says: RewriteEngine on Rewrit...

FreeBSD Server .htaccess issues

Server Details: FreeBSD PHP Version 4.3.11 Apache Appache Modules: mod_throttle, mod_php4, mod_speedycgi, mod_ssl, mod_setenvif, mod_so, mod_unique_id, mod_headers, mod_expires, mod_auth_db, mod_auth_anon, mod_auth, mod_access, mod_rewrite, mod_alias, mod_actions, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_info, mod_status, mod...

htaccess problem with filename

Hi, when I first set up my site I decided to add index.html to the URL but now I have problems with when people remove the index.html and try and access the folder... For example: RewriteRule ^archives/([0-9]+)/([0-9]+)/index.html archive.php?mid=$1-$2 So when archives/07/2009/ it will cause an error, how can I avoid this error? Che...

Using mod_rewrite for subdomains

I wan't people to be able to register their own sections within my site, and have those sections be their own subdomain of my site. so someone can register 'test' and have 'test.example.com' refer to their site which would be at say /site.php?id=1 So how would i go about writing a mod_rewrite rule for this? ...