mod-rewrite

Recursive mod_rewrite for search engine friendly urls

I've been reading through a previous solution to a recursive mod_rewrite problem that is similar to what I'm trying to do, the difference is I'm sending all queries through an index.php file and so don't need to specify the script within the query. Essentially I want to recursively convert any number of parameters within a search engin...

How to mod_rewrite for HTTP_HOST?

I am working in a shared account on a hosting provider with several domain names. Goal is to have each domain name have their own virtual directories. In my personal configured htdocs/ directory, I have a subdirectory set up for each domain name, something quite similar to this: htdocs/ foo.com/ index.html bar.com/ ...

mod_rewrite: Prefer server context over directory context?

Hi, in a product I'm fighting with, I found an .htaccess file at the application root, which basically rewrites requests to non-existing files to a central processing script. For performance reasons I now want to move that rule to my server (virtual host) configuration. The simplest way to do it is to literally copy the rules into a ...

Is it better to use routes or mod_rewrite to forward old URLs?

I recently changed some URLs in my Rails app and am curious if I'm better off using routes + controllers + redirect_to to forward the old URLs, or just use .htaccess with Apache's mod_rewrite? I'm using Apache + Passenger so htaccess files work, but was curious if there was a standard for this sort of thing. FWIW, the URLs were changed...

301 redirect from mod_rewrite RewriteMap program

I'm using mod_rewrite's RewriteMap directive to process URLs. My RewriteMap program is a PHP script and everything is running fine. I'm able to map friendly URLs to PHP program + ID. Anyway, what I want to do is return a 301 redirect for certain URLs. For example, if someone puts in the URL: http://www.example.com/directory1 Then I wan...

Using ModRewrite to get rid of extentions

I would like to get rid of all the file extensions on my site. Except when they are on the index i would like it to say nothing... change this foo.com/index.html to this foo.com/ and when the user goes to another page like foo.com/contact-us.html it will be foo.com/contact-us RewriteEngine On RewriteRule ^ this is where i get confused...

mod_rewrite: Pass the path & query string URL as a parameter

I'm using mod_rewrite to rewrite pretty URLs to a form supported by a Spring 2.5 application. e.g. /category/cat1?q=x => /controller?category=cat1&q=x However from my controller I want to know the original URL the request came from (so I can generate a link if required). This approach is needed generically across all pages so it i...

Redirecting old changesets to other repositories

We have a hook in Mercurial that posts the changeset message and a link the changeset to our bug tracking software. We are using separate repos for each branch. When we are done with a branch we would like to push it to an archive repository and delete the original repo so that the Mercurial page of repositories doesn't get cluttered w...

.htaccess Conditional Redirect When Pattern Does Not Match

I want to enable my users to enter search queries using a URL like this: www.domain.com/searchterm or with a trailing slash like this: www.domain.com/searchterm/ However, I want to capture certain search terms and redirect them to an actual directory. For example, a query like this: www.domain.com/css/site.css should actually point...

RewriteRule (mod_rewrite)

What does that rewrite rule mean? RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] Sorry, even after reading the mod_rewrite syntax explanation, I didn't get it... :-/ Can someone explain me what that rule(s) does. Thanks a lot. ...

Apache RewriteCond to Lighttpd

I want to migrate some sites running on apache to Lighttpd. Can anyone help me to convert this Rewrite rule into a equivalent rule for Lighttpd: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] I'm reading the Lighttpd rewrite explanation (http://redmine.lighttpd.net/...

Mod_rewrite rule

Would there be an easier way to do this with a regular expression? RewriteRule ^2090024$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090024 [L] RewriteRule ^2090025$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090025 [L] RewriteRule ^2090013$ https://www.wsjwine.com/discovery_offer.aspx?promo=2090013 [L] RewriteRule ^20...

What is wrong with this mod_rewrite redirect?

Hi, I have a simple redirect which I just can't get to work and I don't know what's wrong. The server's throwing me a 500 Internal Server Error for no reason I can understand. I'm trying to achieve the following: if a user types the address www.example.com, it will actually be routed to domain/ subdirectory in my server. So if user requ...

IIS 7 Rewrite Rules -> Apache rewrite rules

Besides being a horrible programmer I can't make proper use of Google. I am making a small web site and it uses IIS7 rewrite rules. It all worked good for me until now when I need to migrate it all to Apache and its rewrite rules. Are there tools that can convert ISS rewrite rules (they are XML in web.config) to apache rewrite rules. I...

RewriteCond all domains white www

if i have a domain www.domain1.com and www.domain2.com on same folder, how can i get the the www.(domain.com) go to domain.com? hob sombardy can help me :) my ownd idé is RewriteCond %{HTTP_HOST} www.%{HTTP_HOST} RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=301,L] but i don't know about it will work. ...

.htaccess remove file extension before hashtag

http://freddygonzalez.me/dev/update/index.html#mywork.html How can I use .htaccess to remove the index.html So it could look like this http://freddygonzalez.me/dev/update/#mywork.html Also there may be one conflict.If the user press on the logo they get this http://freddygonzalez.me/dev/update/index.html#index.html So is there a way ...

Is my redirect not removing final slash?

Hello all, I have a site that I don't think my htaccess is implementing 301 redirects properly, I think my problem may be at the application level but I would appreciate it if someone can confirm the following works as I expect it to. Example redirect: http://www.siteic.com/a/b/c/ should go to http://www.siteic.com/a/b/c - however the ...

How can I force 'www' subdomain w/ Apache2 + Rails + Phusion Passenger?

My clients want to use 301 redirects to force the 'www' subdomain on their sites. So 'example.com/something' resolves to 'www.example.com/somthing' etc. What I'm trying to do is simply add this to my vhost file: <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName example.com ServerAlias www.* DocumentRoot /data/...

htaccess rewriterule

A fairly basic htaccess question, but I don't use it much, so i have no idea. I want to check if the requested file exists. If it does, forward to one page, and if not forward to another page and pass the requested path as GET. Thanks in advance. ...

.htaccess whit multi domains problem

i have this .htaccess rule RewriteCond %{HTTP_HOST} ^domain1.com RewriteRule (.*) http://www.domain2.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} www.domain1.com RewriteRule (.*) http://www.domain2.com/$1 [R=301,L] and right now i hav this code RewriteCond %{HTTP_HOST} ^www\.(.*) RewriteRule (.*) http://%1/$1 [R=301,L] the problem is ...