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
55 views

mod_rewrite change . to -

I'm moving my site and the URL structure has changed because of the new CMS. The urls would be similar to /my.products.htm on the new site we are changing the URLs to this /my-products is their a way ...
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 ...
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
609 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/ -> ...
1
vote
1answer
380 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 ([^/]*) ...
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 ...
1
vote
1answer
20 views

Hide query parameters in RewriteRule

I have the following rule: RewriteRule ^farm-products/([A-Za-z0-9-]+)/([0-9]+)/([A-Za-z0-9-]+)/([0-9]+)/([0-9]+)/?$ products.php?$1&page=$2&what=$3&t=$4&cat=$5 The user sees: ...
1
vote
1answer
31 views

Apache URL redirection not working with mod_rewrite

I want to redirect the URL: http://example.com/site to http://example.com/~username/site I have the following in my httpd.conf file: RewriteEngine on RewriteRule ^/site/(.*) /~username/site/$1 ...
1
vote
1answer
24 views

How to eliminate /wiki/ directory in rewrite rule on a site dedicated for a wiki

I have set up a subdomain of my site (for the purposes of this question I'll call it wiki.example.com), installed a wiki there, and set up URL rewrite according to the article on MediaWiki's website ...
1
vote
1answer
90 views

Masking / mapping URL's with .htaccess

I've recently been trying to come up with a way of masking the visible URL in the browser (so not 301 redirecting) and still show the same content as the original URL. Here is the scenario... ...
1
vote
1answer
135 views

Using RewriteBase in .htaccess to make links pretty

I'm working on a project right now and I'm trying to make the links pretty. We have urls like this: http://subdomain.domain.com/DynamicCountry/DynamicName/file.php What I'm trying to do is set the ...
1
vote
2answers
748 views

Remove .php and id from URL and replace with slash

I have tried lots of URL rewrite rules in .htaccess but I am stuck now. I have to change this URL: products.php?id=31 to products/31 I have used: Options +FollowSymLinks -MultiViews ...
1
vote
1answer
112 views

Rewrite URLs not working - wrong method or conflict?

I've been at this for about an hour now and I'm not having much luck. htaccess files are quite new to me, so I'm obviously doing something very wrong. Current htaccess content, which I need to keep: ...
1
vote
1answer
85 views

Would phpBB break if I move it from one folder to another? Can I use mod_rewrite to redirect requests for that forum from old folder to new one?

Please note that I have installed dynamic web pages (PHP) in the directory *public_html/old/* in order to create the web site www.example.com. Actually I have created a PHPBB forum and thus the URL of ...
1
vote
1answer
335 views

.htaccess rewrite wildcard folder paths from host

My desired result is change a file to root / from a N number of paths. For example: www.host.com/a/b/c/e/f/g/images/1.jpg, where A~G is not always given. Result: www.host.com/images/1.jpg. This is ...
1
vote
1answer
81 views

.htaccess problems with redirection

I apologize ahead of time that this might be a common question, however I've spent 3-4 hours already on solutions which don't quite fix the problem. I have a site and it is moving to a different ...
1
vote
2answers
120 views

One .htaccess file with rewrite rules for all domains

Our server is configured with multiple domains which reside in subfolders of the public_html folder. So domain1.com is located in /home/user/public_html/domain1.com and domain2.com is located in ...
1
vote
2answers
23 views

Setting up mod rewrite

I spent hours in finding how to make my url pretty but no luck. I am hosted in DreamHost and using php under fcgi. I'm triying to make my: ...
1
vote
1answer
169 views

Getting the masked URL values in Mediawiki

I have successfully masked the URL in Mediawiki. By using the following scripts in .htaccess and localsettings.php files in Mediawiki, i.e.: .htaccess: Options +FollowSymLinks RewriteEngine on ...
1
vote
1answer
188 views

Silent redirection not working with mod_rewrite

I'm trying to grasp apache mod_rewrite When I add this to my .htaccess it silently (url doesnt change) shows page bob.htm RewriteEngine on RewriteRule index.htm bob.htm I.e. If I type this in the ...
1
vote
1answer
55 views

Redirecting previous domain subfolder links

I've recently bought a domain that was unregistered. After looking in Google webmaster tools, Google is trying to crawl random pages that don't exist. Turns out it did have a previous owner. The ...
1
vote
1answer
319 views

Don't $_GET value on link rewrite with .htaccess

I config enable htaccess on my server (i enable mod_rewrite and do like this: http://stackoverflow.com/questions/11064005/enable-htacess-error-on-ubuntu-12-04-with-apache2) But on localhost is run ...
1
vote
1answer
73 views

Empty Cookie based on IP address

Is there a way to empty a previous cookie based on source ip? I need this to be done because of loadbalancing issues. regards Geert
1
vote
1answer
90 views

Redirect www to non-www only for https://

I can't seem to find a nice way to redirect https://www.x.co.uk to https://x.co.uk whilst letting http://x.co.uk and http://www.x.co.uk keep whatever they want. Could anyone lend a hand? I have ...
1
vote
2answers
187 views

How to setup up .htaccess rewrites for http and https on the same site?

I'm having some issues with htaccess rewrites i need to redirect different parts of my site to HTTPS rather than HTTP, for example login and news sections. I'm not sure how to go about doing this in ...
1
vote
2answers
255 views

WordPress .htaccess preventing subfolder access

This is sort of a goofy setup, but it's not in my power to reconfigure it at this time. I'm running in a shared hosting environment. The domain is example.com. This is an add-on domain on the host ...
1
vote
1answer
199 views

Removing 301 redirect from site root

I'm having a look at a friends website (a fairly old PHP based one) which they've been advised needs re-structuring. The key points being: URLs should be lower case and more "friendly". The root ...
1
vote
2answers
264 views

How do I redirect www and non but not IP

I am trying to redirect www.domain.com or domain.com to www.domain.com/temp.html I am using the following code: RewriteCond %{HTTP_HOST} ^.*$ RewriteRule ^/?$ ...
1
vote
2answers
335 views

WordPress mod_rewrite redirect specific folders

As a new user, I'm not allowed to post more than two hyperlinks here. So I have added a space after every http (ignore them and read as full URLs). System: Debian Etch, Apache 2.2 I have a WordPress ...
1
vote
2answers
276 views

.htaccess remove index.php/url/ from URL

.htaccess is not working. /index.php/user -- is working http://www.example.com/user is not working Current .htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond ...
1
vote
1answer
1k views

Redirecting not working properly in Firefox 9 (or any older version for that matter)

How do I fix a redirect in Firefox so that it leads my site to another address but with a slash at the end of it? This is my redirect in .htaccess: RewriteCond %{HTTP_HOST} ^test\.mydomain\.com$ ...
1
vote
1answer
1k views

Apache rewrite rule for all pages after domain name

I asked this question on stackoverflow.com: http://stackoverflow.com/questions/8466321/apache-rewrite-rule-for-all-pages-after-domain-name Sorry for redirecting, but I wasn't aware of ...
1
vote
2answers
702 views

URL rewrite subfolder to root and forbid accessing subfolder

I have Drupal installed in a subfolder drupal but I want to access pages as it is in root folder: http://www.example.com instead of http://www.example.com/drupal I'm able to have this working, but ...
1
vote
3answers
700 views

Transparent PHP script execution using mod_rewrite

I am looking for a solution for this a problem: I need that every HTTP request (method is irrelevant) in Apache http server would be served only after execution of specific PHP script. This is needed ...
1
vote
1answer
414 views

403 error with a 301 redirect in .htaccess

I wrote a rewrite rule for one of my pages. This rule is supposed to be for a specific single URL only hence the "static-ness". RewriteRule ^picks/categorizedPicks/126$ ...
1
vote
1answer
293 views

how can I set my site root from: localhost/mysite/ to: localhost/mysite/view/ via htaccess

hi just wondering if this is possible, when you access my default site directory localhost/mysite I want to set the path to render localhost/mysite/view/ all my html pages will be rendered here just ...
1
vote
1answer
45 views

Tricky mod_rewrite challenge

I list about 9,000 records on my little site. At the moment I'm showing them with a dynamic page, like http://domain.com/records.php?id=019031 But I'd like to start using meaningful URLs like this ...
1
vote
1answer
186 views

Apache Redirect based on directory name

I'm trying to use one install of Kohana to manage two separate sites rather than just duplicate the install. I have directories like this: applications/ app1/ app2/ The .htaccess I have ...
1
vote
1answer
1k views

mod_rewrite causing too many redirects

The .htaccess we have in our document_root directory is as follows: RewriteEngine on RewriteRule ^posts/1/first-post-title$ /posts/1.html [L] RewriteCond %{REQUEST_URI} ^/posts/1 RewriteCond ...
1
vote
1answer
251 views

301 Redirect are these URLs equivalent?

I want to redirect an entire duplicate directory to the same files in the directory above the dup_folder. Redirect Code in .htaccess: Redirect 301 /dup_folder/ http://www.example.biz/ It redirects ...
1
vote
1answer
355 views

Infinite redirect loop in cPanel-purchased script

I am installing a script (that I bought on cPanel) in the root directory of my web site. When I try to install it, it gives me an error. I found that it starts an infinite URL redirect loop containing ...
1
vote
1answer
5k views

How to setup mod_rewrite/htaccess to do url masking and forwarding to a subdirectory?

Its been about three years since I've played with apache and php(I've been using thin and nignx ;). So I've forgotten how to setup a mod_rewrite directive to forward all http requests from root to the ...
1
vote
1answer
2k views

Setting Content Type with mod_rewrite

I have the following mod_rewrite rule: RewriteRule ^/yui-3.3/yui_config.js$ /web/yui/yui_config.js [R] when looking at the network traffic with Firebug and Chrome I noticed that ...
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 ...
1
vote
1answer
860 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
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 ...
1
vote
0answers
18 views

Apache URL rewriting with masking and includes outside of DocumentRoot

I have an Apache 2.2.15 web server with the primary site at /web/mybiz which corresponds to http://mybiz.domain.com. We now have a new subdomain http://abc.mybiz.domain.com with the homepage living at ...
1
vote
1answer
31 views

Using Mod_Rewrite To Block Referrer Based On Domain Extenstion?

I've been in web development for several years now (I'm a student web designer), and recently, I've begun to experiment with mod_rewrite for things like URL shortening. I was wondering, is it ...
1
vote
1answer
74 views

Can't get Rewrite rule to keep original URL

I have these Rewrites, but I would like to have the URL stay the same as what is typed originally, I thought removing the [R] flags would stop it but it hasn't RewriteCond %{HTTP_HOST} ...