mod-rewrite

Replace %26 in htaccess to something else

Hi all, Basically I'm importing a bunch of pages that have ampersands in the title, from Mediawiki. These are encoded as %26. Drupal, for various reasons, has decided double encode the url it to have it become %2526. I simply can't create the alisis within Drupal so I have to use htaccess tl;dr: I need example.com/something_%26_else ...

Problem with Wordpress permalinks and mod_rewriter

Hi there, first off...thank you so much for your time. I was referred to you guys and heard here's the best place to find a solution. Ok...so here's the problem. My old programmer set up the wordpress permalinks to be dynamic, but we all know that they are the worst to pull in traffic from search engines (specially google). So I need...

Use mod_rewrite to redirect from folder to index.asp file, if such file exists

Hi there, I'm using Rackspace's Cloud Sites as a webhost and, for a site that uses both PHP and ASP, they have a funny setup. On our setup, PHP is the default technology, and so the site by default runs Apache, until it hits a URL ending with the .asp extension. That means this URL: www.site.com/folder/ Will not automatically load: ...

How does Code Igniter know that index.php is not a directory?

My Code Igniter app has urls like this: http://servername/contexttroot/index.php/Sessions/login/ My question is, when the url is parsed how does Apache know that there isn't a folder called index.php? If I were the parser, that's what I would be looking for :) I know it works and CI's index.php gets called but I don't understand how t...

.htaccess Redirect from subdomain to domain

I've tried a bunch of examples here on SO and modifed them, but none are exactly what I need and as a result either fail with 500 server errors (meaning the rewrite rules are wrong) or redirect just the subdomain to the domain and not any of the full URLs of pages. I need to redirect all URLs under blog.mydomain.com to www.mydomain.com/...

is restarting apache service needed with any changes to rewritemap file?

I am using a perl script file as a map file in RewriteMap directive. As i read the apache load the script once at the beginning, So is it needed to reload or restart apache after any changes to this script file? ...

mod_rewrite on fasthosts.

Hello there kind people. I've installed Wordpress here http://www.trsmithroofing.co.uk/flat_roof_blog and I've noticed that URL re-writes are working nicely. Here's an example of one. http://trsmithroofing.co.uk/flat_roof_blog/index.php/2010/10/single-garage-flat-roof/ Knowing this works, I'm wondering why I cannot get re-writes t...

Setting an apache reverse proxy as a gateway between client cert authentication (mod_ssl) and basic authentication for backend server

Hi, I have a backend server that expects a Basic HTTP Authentication. I can't touch this server and its authentication mode. But, I'd like to replace this authentication by a client certificate on a reverse proxy in front of this server. This would make something like this : User --(ssl auth)--> ReverseProxy ---(Basic Auth with login)...

Redirect not working for complex rewrite rules (.htaccess)

Hello, I'm trying to make a redirect from a non-www version of the link to the www one. Its working fine for something like http://mywebsite.com but it fails for a request like http://mywebsite.com/artists/metallica/ or even a complex one. The whole .htaccess file is bellow. Any clues? Options +FollowSymLinks RewriteEngine On Rewrite...

How to make this mod rewrite

This drives me crazy, it should be easy but I can't... I need to rewrite URLs like this ones: www.domain.com/foo/bar/more/evenmore.htm www.domain.com/foo/bar/more.htm www.domain.com/foo/bar.htm www.domain.com/foo.htm into: www.domain.com/?var1=foo&var2=bar&var3=more&var4=evenmore www.domain.com/?var1=foo&var2=bar&var3=more www.domai...

Redirect/.htaccess to change old PHP parameter URLs to SEO friendly CakePHP URLs?

I'm about to update my site to use CakePHP instead of an old homegrown framework. I need to write the HTAccess file to redirect the old PHP parameter URLs to the new CakePHP SEO friendly urls, but I can't get it to work. My htacess file (the one in app/webroot) looks like this at the moment: RewriteEngine On RewriteRule ^index.php?a...

.htaccess regex in RewriteRule matches, variables remain empty

I have some conditions and rules in my .htaccess: RewriteCond %{DOCUMENT_ROOT}/assets/img$1/.$2.$4/$3.$4 -f RewriteRule ^assets/img(.*)/[a-zA-Z0-9-_\.]*\.[^/]+\.[a-z]{2,4}$ assets/img$1/.$2.$4/$3.$4 [NC] RewriteRule ^assets/img(.*)/[a-zA-Z0-9-_\.]*\.[^/]+\.[a-z]{2,4}$ assets/img/image.php?path=$1&file=$2.$4&template=$3 [NC,L,QSA] The ...

.htaccess redirect doens't work correctly

Hi, I'm using a .htaccess to get all documents from an old site to the new one. The old site doesn't support PHP or mod_rewrite. I tried the following code: Redirect 301 / http://www.new.com/archive/ I requested " http://www.new.com/archive/index.html" Which resulted into http://www.new.com/archive/old.com/olddir/&&&/&am...

[PHP] Detect if script in Domain Root or Subdirectory

Hi, I have written a small php script which uses clean urls for which mod_rewrite rules are used. that script needs to know where is located in order to run. root domain : yourdomain.com sub dir yourdomain.com/subdir/ Currently to set path for the script. I use following two, Case: root domain: define("ScriptURl",'http://'.$_SE...

Apache RewriteRule removing submit x y coordinates from Querystring (Mac Snow Leopard OS X)

This ought to be a simple exercise in Apache with mod_rewrite and all of it's flexibility. I have verified the Rewrite module is working with full logging but no matter how I shake out my rules and conditions, I can't get it to work. What I want is to rewrite the following url: http://www.domain.com/search?x=10&y=10&query=sear...

How would I write a RewriteRule to make redirection

I want to rewrite the html and xml files and directories to the pagename query string using .htaccess file. like this : mysubsite/category_1/category_2/ mysubsite/category_1/category_2/file1.html mysubsite/category_1/category_2/file2.152.html index.php?pagename=category_1/category_2/ index.php?pagename=category_1/category_2/file1.html ...

.htaccess questions

Say I have the following .htaccess file: RewriteEngine On RewriteCond %{HTTP_COOKIE} name=value [NC] RewriteRule ^image01.gif$ http://www.domain.tld/images/partner/image01.gif [NC,QSA] RewriteCond %{HTTP_COOKIE} name=value [NC] RewriteRule ^image02.gif$ http://www.domain.tld/images/partner/image02.gif [NC,QSA] What do NC and QSA mea...

Add Trailing Slash to URL

My current .htaccess file looks like this: RewriteEngine on RewriteBase / Options +FollowSymLinks -Indexes RewriteRule ^video/(.*)$ video.php?id=$1 [L] RewriteRule ^video/(.*)$([a-zA-Z0-9]+) video.php?id=$1 [L] RewriteRule ^tag/(.*)/page-(.*)/$ tag.php?tag=$1&page=$2 [L] RewriteRule ^tag/(.*)/page-(.*)$ tag.php?tag=$1&page=$2 [L] Rewr...

Can someone explain this strange mod_rewrite regex behavior

I've been working on a script for debugging mod_rewrite, and when testing their regex system I've had some strange results. I'm wondering if this is normal behavior for the mod_rewrite regex engine or if some part in my code is causing it. Requested URL: http://myurl.com/path/to/something .htaccess has: RewriteRule to where Using my d...

mod_rewrite with exceptions

For redirecting every request on my server to a secure connection I use RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://mywebsite.com/$1 [R,L] which works perfect. However I need two paths not to be redirected. Say when I access http://www.mywebsite.com/page1/test http://www.mywebsite.com/page2 I want to go to exactly t...