mod_rewrite is a URL rewriting module for the Apache web server. It is commonly used for so-called "pretty" URLs because of its ability to redirect on the server side (transparent to clients and their browsers), but also provides the power and flexibility to perform various request handling tasks ...

learn more… | top users | synonyms

1
vote
1answer
1k views

mod_rewrite with Apache -> mod_jk -> tomcat

Related to some of my earlier questions. I now have a setup I quite like; Apache httpd listening on port 80 accepting http and https connections. Several Tomcat instances running on several AJP ...
3
votes
4answers
2k views

How to create .htaccess to block access to a subdirectory that hosts a separate domain

So I am pretty noob at with creating code in .htaccess, but I know it is what I need to accomplish a pretty simple task. So here is what I want to do. I have a main domain, (me.com), and I am hosting ...
1
vote
1answer
129 views

How do I get rid of the “www” with mod_rewrite?

I want to get rid of the "www" in front of my domain, and I'm trying the following, but it's not working: RewriteEngine On RewriteCond %{HTTP_POST} ^www\.example\.com [NC] RewriteRule ^/(.*) ...
2
votes
2answers
1k views

How can I redirect everything but the index as 410?

Our site shut down and we need to give a 410 redirect to the users. We have a small one-page replacement site set up in the same domain and a custom 410 error page. We'd like to have it so that all ...
3
votes
2answers
476 views

How do I redirect an English language URL to an Arabic language URL?

I have a link that's currently formatted like this: http://site.com/news/view/1.html I want to it redirect it to: http://site.com/خبر/عنوان-الخبر where خبر is equal to news and عنوان-الخبر is ...
0
votes
1answer
265 views

How to block access to a sub-site with mod_rewrite?

Let's say I have the sites siteA.com and siteB.com. They are hosted such that siteB.com actually points to siteA.com/siteB. How can I block someone from visiting siteA.com/siteB using mod_rewrite? ...
2
votes
3answers
293 views

Mod Rewrite question

Is there a way to rewrite http://localhost/embed/player.swf?file=http://www.youtube.com/watch?v=7yKDhm4_-90 to something smaller? or is there a way to change this into ...
1
vote
2answers
99 views

rewrite on urls to add “/”

I know how to rewrite urls to redirect to a page. When the "/" is not at the end of www.DomainName.com/user/myUserName the redirect works: RewriteRule /$ /user/index.php When I write RewriteBase / ...
1
vote
2answers
618 views

.htaccess rules to rewrite URLs to front end page?

I am adding a new application to my site at example.com/app. I want views at that URL to always open myapp.php. E.g. example.com/app -> example.com/app/myapp.php and example.com/app/ -> ...
0
votes
2answers
170 views

Help with Apache mod_rewrite rules

I want to change some legacy URL's like this: /modules.php?name=News&file=article&sid=600 to this: /news/story/600/ This is what I have tried: RewriteEngine on RewriteCond ...
1
vote
1answer
398 views

Regex Needed to allow mod-rewrite rule to work either with or without trailing slash?

Given the following rewrite rule: RewriteRule ^user/([^/]*)$ /userprofile.php?user=$1 [L] How can I have it work either with or without a trailing slash? Bonus points, how can I verify ([^/]*) ...
5
votes
1answer
874 views

How to internally rewrite a page when requested from specific HTTP_HOST

I have a Drupal site, site.com, and our client has a campaign that they're promoting for which they've bought a new domain name, campaign.com. I'd like it so that a request for campaign.com internally ...
0
votes
2answers
161 views

Is it possible to mod_rewrite BASED on the existence of a file/directory and uniqueID?

My site currently forces all non www. pages to use www. Ultimately, I am able to handle all unique subdomains and parse correctly but I am trying to achieve the following: (ideally with ...
0
votes
1answer
680 views

.htaccess: Redirect Hotlink Flash --> Site with embed Flash

I have some PHP sites that embeds SWF files. These SWF files are now linked to by some other guys. And I don't want them to simply open the SWF, I want them to force being redirect to the page where ...
1
vote
3answers
2k views

Using env variables with RewriteRule and ErrorDocument

I'm having problems with the following while config. my Apache server to Rewrite some urls. SetEnv PATH_TO_DIR /directory RewriteRule ^%{PATH_TO_DIR}/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-\.]+)/?$ ...
1
vote
1answer
75 views

wrestling with some rewrites for Apache

I have upgraded my gallery2 to gallery3, and notice that some links no longer resolve correctly. Since the proper way is to redirect these with a 301, that is the way I'm going. The following series ...
1
vote
1answer
883 views

Mod_rewrite on Amazon S3

Is it possible to use mod_rewrite on Amazon S3? www.example.com/about.html -> mybucket.s3.amazon.com/index.html www.example.com/welcome.html -> mybucket.s3.amazon.com/index.html ...
1
vote
2answers
2k views

apache domain redirect to subfolder

I have a hosting account with godaddy. Its a linux system running apache. The way they do their setup is your primary domain is the root folder. When you add a subdomain its in a subfolder of the ...
1
vote
3answers
162 views

How to remove a file from url using mod_rewrite

I want http://www.foo.com/ to internally point to /var/www/home.php and http://www.foo.com/home.php to be redirected to http://www.foo.com/. Thus, I would like to fix the old ...
2
votes
2answers
3k views

Mod Rewrite - directing HTTP/HTTPS traffic to the appropriate virtual hosts

I have an Apache2 web server (v. 2.2.16) running on Debian hosting three virtual hosts. The first two hosts are HTTP only (server1 and server2). The last host is HTTPS only (server3). My virtual host ...
0
votes
1answer
538 views

Apache mod_rewrite for multiple domains to SSL

I'm running a web service that will allow people to create their own "instances" of my application, running under their own domain. These people will create an A record to forward a subdomain of their ...
3
votes
2answers
5k views

Rewrite for robots.txt and favicon.ico

I have setup some rules in which subdomains (my users) will default to where I have located the robots.txt, favicon.ico, and crossdomain.xml therefore if a user creates a site say ...
0
votes
2answers
85 views

RewriteRules targeting a directory result in a gratuitous redirect

I have a standard CMS-like RewriteRule set up in my .htaccess: RewriteRule ^(.+)$ index.php?slug=$1 Let's say I have a directory called "foo" in the root directory. For some reason, if you hit the ...
2
votes
2answers
111 views

Virtual hosting

I want to use domains like xxx.abc.domain.tld. The xxx is my folder to access. I tried it with the rewrite rules, but I can't get it working, because I don't know how to get the part xxx from the ...
2
votes
2answers
871 views

Need some help on tomcat URL mod_rewrite or mod_jk

I am trying to remove the context name from the URL of my server. Current URL - http://www.domainname.com/MyApp/ What I need to make is to make it available at - www.domainname.com/ So it is only ...
2
votes
2answers
647 views

Redirecting a CSS file based on .htaccess rules

I'm trying to hack the css files on OSTicket by replacing them with my own custom ones when a specific URL is accessed. The URL that is accessed for this example is ...
3
votes
2answers
4k views

htaccess execution order and priority

Can anyone explain to me in what order apache executes .htaccess files residing in different levels of the same path and how the rewrite rules therein are prioritized? For example, why doesn't the ...
1
vote
1answer
59 views

Simple mod_rewrite Question

I want to have everything that looks like this: /1/2/3/4/5/[...] to redirect to this: /index.php?u=/1/2/3/4/5/[...] unless the requested string is a specific file. So anything that doesn't have a ...
0
votes
1answer
388 views

Force www. on multi domain site and retain http or https

I am using CakePHP which already contains an .htaccess file that looks like: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) ...
8
votes
3answers
3k views

Forcing SSL and www in .htaccess

I'm looking for a way to force SSL and www. I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a URL in this format: ...
3
votes
1answer
387 views

subdomains apache rewrite rules

Let's say I have my web folder as public_html. In there I have a sub folder. I can view the folder at: www.mydomain.com/sub & mydomain.com/sub What I want is: sub.mydomain.com This will show ...
3
votes
4answers
147 views

Question about mod_rewrite rule for redirecting failing pages

I'm setting up a mod_rewrite rule that redirects failing pages to a custom "Page Not Found" page. This is with WordPress. I've used an online tutorial from the Apache site and so far my rules look ...
4
votes
1answer
7k views

Properly force SSL with .htaccess, no double authentication

I'm trying to force SSL with .htaccess on a shared host. This means there I only have access to .htaccess and not the vhosts config. I know you can put a rule in the VirtualHost config file to force ...
1
vote
1answer
1k views

Using mod_rewrite to send all requests to a certain document

I want to temporarily redirect all requests for a site to index.html, using apache only. Is this mod_rewrite approach going to work, and is it the right way to do it? RewriteEngine on RewriteRule ...
2
votes
1answer
1k views

Joomla 1.6 URL rewrite on IIS7 (removing /index.php/)

Joomla 1.6 was released today and I'm wondering if anyone knows how to get rid of the /index.php/ part? How link looks now: http://www.example.org/index.php/stuff How link would look after URL ...
2
votes
3answers
278 views

How to use .htaccess to show smarter URLs

I'd like to ask how can I call the page www.domain.com/index.php?page=somepage and make the browser show the user in the URL bar the address www.domain.com/somepage/? How do I do that trick?
0
votes
1answer
745 views

Rewrite URL to a PHP script with parameters

I'm trying to create a service that you give it a URL like http://myhost.com/34.png and it will return the result of the script http://myhost.com/create_image.php?count=34. I know this is possible ...
-1
votes
4answers
154 views

Hosting plans that allow more then 1 GB for mysql and easier mod_rewrites? [duplicate]

Possible Duplicate: How to find web hosting that meets my requirements? I'm using godaddy and am thinking of moving to another hosting company that allows easier mod_rewrites and a bigger ...
4
votes
5answers
836 views

Site compromised .htaccess files everywhere

Some of the sites we're hosting are compromised by... I don't know what. Every directory on the webserver contains a .htaccess file which redirects a user coming from a search engine to a page which ...
5
votes
2answers
1k views

How to 301 redirect from old query string URLs to CakePHP Canonical URLs?

I currently have a .htaccess file that looks like this: RewriteCond %{QUERY_STRING} ^action=view&item=([0-9]+)$ RewriteRule ^index\.php$ /index.php?url=item/%1 [R=301] RewriteCond ...
8
votes
6answers
1k views

Poor Man's Clean URLs vs. Mod_Rewrite

At the company where I work, we're getting ready to design a new web site, and there's some disagreement about how to do clean URLs. Over the past year we've been making small improvements to our ...
7
votes
1answer
269 views

Apache rewrite rules for development workstation and server

I've got developers editing pages for several sites on a WAMP stack and then uploading to the public servers running LAMP stacks. We're pretty happy with it, but we have this minor annoyance: we can't ...
5
votes
5answers
13k views

“File does not exist” in apache error log

This is an example of an error in out log file: File does not exist: /var/www/website/female, referer: http://www.website.com/female/dresses/A-Dress-Black "/female" doesn't exist, because we use ...
6
votes
5answers
7k views

How to Remove Extensions From, and Force the Trailing Slash at the End of URLs?

Example of current file structure: example.com/foo.php example.com/bar.html example.com/directory/ example.com/directory/foo.php example.com/directory/bar.html ...