mod-rewrite

mod-rewrite URL Change

I had an issue playing with Gallery when I changed a setting. However, I noticed there is a pattern to the error: The URLs look as such: main.php/d/number/name.jpg "number" is dynamic (ie "9496-2") "name" is dynamic (ie "all+clad+7pc+b") Everything else is static. Unfortunately, when I made the setting change, the "number" portion t...

Removing index.php from website URLs

I am using the Kohana framework (but I think it's irrelevant for this question) and pages can be accessed like so http://www.example.com/articles/ http://www.example.com/index.php/articles/ Now, as a rule of thumb, I generally try and tweak my .htaccess to only allow one way in for a page, and silently redirect other common ways. Ess...

Why does this config code not work in .htaccess?

<VirtualHost *:80> DocumentRoot /lf/main/com ServerName 74.220.215.241/~laborfa2 ServerAlias 74.220.215.241/~laborfa2 RewriteEngine on #RewriteLogLevel 2 #RewriteLog logs/rewrite.log RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f RewriteRule ^/(.*)(/?)$ /$1.php [L] RewriteRule ^/([a-zA-Z]+)([a-...

Help with mod_rewrite rule for dynamic url

Ugh.. mod_rewrite makes me feel stupid. I just haven't wrapped my brain around it yet. :/ I have this url: http://example.com/a/name/ ...that I want to point here: http://example.com/a/index.php?id=name ...where name is what is getting passed to index.php as the id argument. Anything I've tried results in either a 404 or a 500.. :(...

Help with mod_rewrite

Hi ALl I have folder home/admin. In this folder there is index.php. When i access to domain.com/admin/ my mod_rewrite rule redirects it my index.php in the home folder. I want mod_rewrite to skip existing folder or files, and special case for /admin/ folder, which contains index.php file. My rewrite rule is: <IfModule mod_rewrite.c> ...

.htaccess ModReWrite help

I am having some trouble with my ReWrite code. Please note that the .htaccess file is in the subdomain folder (...public_html/subdomain/ ) I am simply trying to rewrite a page request: http://subdomain.mysite.com/home http://subdomain.mysite.com/index.php?page=home My .htaccess file looks like this... RewriteEngine On RewriteRule ^/...

How to rewrite ALL urls while skipping certain folders?

Hi, i'm trying to rewrite my urls to goto a single php file: RewriteRule ^dir/(?:(?!style|js).)*$ http://www.domain.com/single.php?uri=$1 [QSA] However the exclusion of /dir/js and /dir/style isn't working as i was hoping it would... [redirects] domain.com/dir [redirects] domain.com/dir/jason [redirects] domain.com/dir/jason/pete [...

mod_rewrite vs symlink: the browser is not fooled.

I have a file foo.bar.1 on my server and when I try to access it from a browser (firefox) I get a popup that says "You have chosen to open foo.bar.1 which is a: 1 file ... What should Firefox do with this file...". If I create a symlink to it, foo.dat, I can access it just fine; the contents display in the browser as I expect. My probl...

Q2:Why does this config code not work in .htaccess?

What I will use instead of Document_Root in .htaccess?? Following is in my htttp.conf of my linux server. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php -f RewriteRule ^/(.*)(/?)$ /$1.php [L] RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})(/?)$ /profile.php?fairid=$1$2 [L] RewriteRule ^/([a-zA-Z]+)([a-zA-Z0-9_]{3,15})/([a-z]*)(/?)$ ...

.htaccess Rewrite Question

I have a number of pages in my site, as one would expect. For example: index.php submit.php view.php?id=blah I want these rewritten like index/ submit/ view/blah Whats the best way of doing this? ...

What's the best way to issue a 301 redirect in this situation?

Hi all, I have a PHP5/Zend Framework 1.8.1 web site which is located at: http://www.example.com/foo The older version of this site, which infuriatingly, is still maintained by google's index was located at: http://www.example.com/foo/DEFAULT.ASP So a lot of people are requesting the above link and hitting a dead end. I figure, th...

Apache RewriteRule Flag error

I'm having problems with the follow code: Options FollowSymLinks RewriteEngine on RewriteRule ^thing/([^/]+)/?$ index.php?t=$1 [B] I'm getting "500 Internal Server Error" The error log says: RewriteRule: unknown flag 'B' I've check my Apache version: [root@server ~]# httpd -v Server version: Apache/2.2.3 Server built: Jan 21 2...

Strip specific parameteters when redirecting with Mod-Rewrite

I have a pretty complex RewriteRule where I need to check if certain parameters are present in QueryString and then redirect to the same URL but with those parameters stripped. How can I remove some parameters and preserve the rest? RewriteCond %{QUERY_STRING} color=red RewriteCond %{QUERY_STRING} status=contiue RewriteRule ^(.*)$ /$1?...

mod_rewrite - point css/images/js files to specific directory

On my hosted server, the files are located here: /usr/home/user1/public_html I have to access the files using something like this: http://server1.example.com/user1/ However, all my files use absolute paths to reference CSS / Images / JS files. So, my requests for these assets look like this: http://server1.example.com/images/homepag...

How can I set up a reverse proxy with mod_proxy without redirecting?

How can I set up a reverse proxy with mod_proxy without redirecting to another server or IP? This will be a virtual host environment. The reason I want to do this is so that mod_proxy handles the communication with the client's browser thereby freeing up web server processes to serve the next request instead of feeding the client's brow...

Search and replace in apache htaccess a RewriteRule

I'd basically like to get /path/file+name+with+plusses.mp3 to rewrite to /path/file name with plusses.mp3 In my case wordpress is intercepting the request and giving a 404. But the file does indeed exist. Given the constraints of the regex in mod_rewrite implementation, I haven't yet seen a straightforward way of doing this. ...

how to use "AND", "OR" for RewriteCond on Apache?

Is this how to use AND, OR for RewriteCond on Apache? rewritecond A [or] rewritecond B rewritecond C [or] rewritecond D RewriteRule ... something becomes if ( (A or B) and (C or D) ) rewrite_it. So it seems like "OR" is higher precedence than "AND"? Is there a way to easily tell, like in the (A or B) and (C or D) syntax? ...

Redirecting a Directory to a Script on Apache

So I'm playing with a script that makes it super easy to mirror images off of the web. The script works great (based off of the old imgred.com source, if you've seen that) problem is, it looks a little clunky when using it. Currently, in order to use the script, you go to a url like: http://mydomain.com/mirror/imgred.php?Image=http://o...

Mod Rewrite Skip Rules Server error

The following code gives me an internal server error and I cannot determine why. RewriteEngine On SetEnv APPLICATION production RewriteCond %{ENV:APPLICATION} =production RewriteRule ^.*$ - [S=1] RewriteRule ^(.*)$ html/$1.html All it should do is take the url /test and turn have it reference /html/test.html behind the scenes, ...

.htaccess Question

I have a login script using PHP. The variables for login in and out are log.php?do=in and log.php?do=out I would like to change this to log/in and log/out if possible. Im really struggling to understand .htaccess and the rewriting at the moment ^^ ...