mod-rewrite

Am I missing a flag or something? RewriteRule tip needed

RewriteEngine On RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?p=$1&l=$2 RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ index.php?p=$1&l=$2 this works fine if I do site.com/param_one/param_two/, but returns a 404 when I omit param_two. I'm a newbie to routing requests with htaccess, is there a simple quick fix? ...

Apache mod_rewrite - forward domain root to subdirectory

I have what I originally assumed to be a simple problem. I am using shared hosting for my website (so I don't have access to the Apache configuration) and have only been given a single folder to store all my content in. This is all well and good but it means that all my subdomains must have their virtual document root's inside public_htm...

Apache and Rewrite Module

I created a file .htaccess in the /var/www directory. The rights are "root root --wxrwxrwxr". The content of the file is: Options +FollowSymlinks RewriteEngine on RewriteLogLevel 3 RewriteLog "/var/log/apache2/rewrite.log" RewriteRule ^(.*?)$ testphp.php When I call the page phpinfo.php, I've got: Loaded Modules ... mod_rewrite ... ...

Problem with mod rewrite for multi-lingual site

Hi everyone Currently developing a multi-lingual website, Users can access the front page using URL with format below: http://example.com/en/ http://example.com/fr/ Problem is here. URL without last "/" (http://example.com/fr) caused page not found problem Here is the rule RewriteRule ^/?([^./]+)/(.*)$ $2?lang=$1 [L,QSA] Can anyb...

mod_rewrite: no ? and # in REQUEST_URI

Hello. What I'm trying to do: have pretty URLs in the format 'http://domain.tld/one/two/three', that get handled by a PHP script (index.php) by looking at the REQUEST_URI server variable. In my example, the REQUEST_URI would be '/one/two/three'. (Btw., is this a good idea in general?) I'm using Apache's mod_rewrite to achieve that. Her...

Redirect for .htaccess Wildcard Subdomains

Hello, I've been trying to figure out a way to redirect requests for wildcard subdomains to a specific folder ( called 'core' ) and calling the requested page/file from that specific folder. For example, making all calls to -http://johnny5.mysite.net redirect to -http://mysite.net/core/, or -http://docholliday.mysite.net/login.php redir...

How do I interpolate values in the TestString portion of an .htaccess RewriteCond?

How do I interpolate values like %{REQUEST_FILENAME} in the TestString part of a RewriteCond directive? Here's what I'm trying to do: # non-existent requests to /webroot files get 404'd RewriteCond site/%{REQUEST_FILENAME} !-f RewriteRule ^/?webroot site/webroot/404 [L] # otherwise, let them in! RewriteRule ^/?webroot/(.*)$ site/webroot...

How do I redirect a not found FLV file to a 404 FLV file, using .htaccess?

Using .htaccess, how do I permanently redirect all not found *.flv files in one directory to a 404.flv file in the same directory. For example: If this file is not found: example.com/flv/*.flv Use this file: example.com/flv/404.flv Here's what I have so far (I'm very bad): RewriteCond /flv/(.*).flv !-f RewriteRule ^ /flv/404.flv [L,R...

Apache mod rewrite .htaccess problem

My site is a php based site, but I've added wordpress in a /blog/ folder. The .htaccess file below should allow the /blog/ folder to be accessed, but I get a 404 error saying that blog.php doesn't exist. <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !\.(gif|jpg|png)$ RewriteCond %{REQUEST_FILENA...

503 server response for Googlebot

I put an .htaccess file in my webroot with the following contents RewriteBase / RewriteCond %{HTTP_USER_AGENT} ^.*(Googlebot|Googlebot|Mediapartners|Adsbot|Feedfetcher)-?(Google|Image)? [NC] RewriteRule .* /var/www/503.html This website is in maintenance mode, and I don't want anything indexed yet. I tested the code with a firefox Use...

Problem switching back from forced SSL on certain pages using mod_rewrite

Client wants login pages to load via https. This is easily accomplished, but since the site uses pretty url's, we now stay in https mode when clicking around after login is finished. This breaks secure files which are uploaded in the CMS, stored above webroot, and downloaded by streaming through a php script if user has the appropriate...

How to prevent redirect loop with ManagedFusion URL Rewriter?

Using ManagedFusion's URL rewriter, I have the following code. When requesting / on the Visual Studio development server, I get a redirect loop, however the same code works on a production IIS server when I upload the site to it... why is this? I have <defaultDocument enabled="false"/> in the web.config. RewriteRule ^/(Default|index|hom...

What causes Apache Environment Variable set using mod_rewrite to have "redirect_" appended to name?

I am trying to set Apache environment variables (for use in PHP) with the [E=VAR:VAL] flag on RewriteRule rules in an .htaccess file. I have already discovered the variables are accessed in PHP as server variables $_SERVER rather than $_ENV (which makes a certain amount of sense). However, my problem is for some rules the [E=VAR:VAL] fl...

Redirect with htaccess for images onto another server without redirect looping

Hey guys, I currently have a host where my main site is hosted on. I have set up nginx on another server to mirror/cache files being requested if it doesn't have it already, in particular images and flv videos. For example: www.domain.com is my main site. www.domain.com/video/video.flv www.domain.com/images/1.png I would like to as...

Drupal htaccess redirect - all files in directory to new directory

Hiya, I've moved a site to Drupal, but am now getting a lot of 404 errors due to the search engines taking their time to update the indexes. The 404 paths all look similar to this: recipedata/ccp1300006/633_L.jpg recipedata/ccp1500005/risotto.jpg recipedata/ccp1500006/haddock.jpg So I'd like to do some htaccess redirection with mo...

URL rewrite using .htaccess

I need a url like mydomain.com/myname/?action=post&data=10 here in a single php page(user.php) i need all 'myname','post' and '10' as get method variables. How can i get it using .htaccess???... plz help me..... ...

Apache Rewrite - put parts of query string in replacement string

Hello, I'd like to rewrite: www.example.com/file.html?username=john&number=1234 To: www.example.com/users/john But I can't figure out how to extract the "username" value from the query string. I've been Googling this all morning and reading the official docs but no luck. I need to solve this problem with a rewrite, rather than chang...

Using .htaccess to replace backslash in URL with forward-slash

I realise that a backslash should never appear in a URL in a form other than a URL escape code, however in this case the URL's are being generated by a .NET application for generating flashbooks. I have contacted the developer of this application with a bug report. In the interim i would like to use .htaccess to rewrite the offending b...

Mod_Rewrite: Testing URL got indexed in Google - How do I create a proper 301 redirect?

I worked on a website for which I had a "development URL" that looked something like this: www.example.com.php5-9.dfw1-2.example.com/ Now, several weeks after the website launch, there is at least one page of content indexed on Google with that URL. Question: How do I redirect all requests from that test URL to reroute to the actual ...

Changing /page.php to /page/

Hey there, I'm trying to change all http://www.mysite.com/filename.php files to show as http://www.mysite.com/filename/ using mod_rewrite, but I seem to be doing something wrong. Can anyone help out? I'm guessing it's something pretty simple for those that know. Thanks. ...