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
votes
0answers
15 views

Hiding and redirecting extensions on my webpage [duplicate]

I want to hide extensions on my webpage using the .htaccess file. I have managed to do it by using this code; RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php ...
2
votes
1answer
37 views

How to add the ‘www’ prefix to my domain

I am trying to add www to my domain. I have the custom PHPcode on live server. I have workout GoDaddy forward options also but still my domain not forward. I have a site designed in Core PHPand was ...
1
vote
1answer
9 views

Bypass all rules and redirect internally to another folder/file

In Apache config file, there are some rules defines like below: <IfModule mod_rewrite.c> RewriteRule ^(Category)/([^/]+)/(.+)$ index.php?module=$1&id=$2&action=$3 [B,L,QSA] ...
1
vote
1answer
58 views

When a mod_rewrite redirect is in place, do absent <img>s still cost more server time than present <img>s?

I have a series of webpages in which the <html> refers to: <img src="img1.png" [...] /> <img src="img2.png" [...] /> <img src="img3.png" [...] /> After I realised that ...
1
vote
1answer
31 views

How can I pass optional URL parameters through my rewrite rule?

I created a CMS that identifies if the GET value of url is defined, and if it is, it returns the html contents of the page from the frontend template on index.php. This ideally is to make a templating ...
1
vote
0answers
96 views

Can Apache .htaccess convert the percent-encoding in encoded URIs from Win-1252 to UTF-8?

I want to add a directive in my .htaccess, such that if the browser is pointed at a URI containing %E4 (ä) - or any other special character - the .htaccess automatically rewrites %E4 (ä) as %C3%A4 ...
0
votes
2answers
41 views

Remove folder name from rewritten URLs

Consider this URL: http://example.com/gallery/20141111-some-title In this URL I want to hide gallery/: http://example.com/20141111-some-title How can I achieve this using mod_rewrite? I used ...
2
votes
1answer
33 views

How use a canonical link tag in a dynamic page?

<link rel="canonical" href="http://www.example.com/category/subcategory/example-product/product-id" /> I have a whole bunch of query string URLs (company products) that I have rewritten to ...
2
votes
1answer
35 views

Forbid users from accessing a long URL while allowing access to a shorter one with mod_rewrite

I'm trying to block the following URL: www.example.com/Ayurveda/article/guna/alkalizing/contains/non-vegan/experience/relieves-burning But I want to allow: ...
1
vote
1answer
28 views

What rewrite rule would show the 410 (gone) status for removed forum URLs?

I have removed a forum system from my CMS and now I want to return an 410 status code whenever a search engine visits the former posts. I know that I have to use a number of Rewrite Rules to do the ...
1
vote
2answers
133 views

Remove trailing slash and index.html in .htaccess

I seem to be stuck here trying to figure out how to redirect the following scenarios: /foo/index.html -> /foo (remove trailing slash, index.html as 301) /foo/ -> /foo (remove ...
1
vote
2answers
383 views

RewriteRule /change-email.htm?e=someone@somewhere.com&h=xxxxxx

I need to rewrite URL's of this form: /change-email.htm?e=someone@somewhere.com&h=xxxxxx to: /change-email/?e=someone@somewhere.com&h=xxxxx I've done this in my .htaccess: RewriteCond ...
1
vote
1answer
72 views

Redirecting domain to subfolder, one hosting account, avoid redirect loop. masking?

i know similar questions have been asked, but i've been at this for weeks. please humor me! i have two domains (giving actual domain names for simplicity and also to avoid in-head conversions for my ...
1
vote
1answer
42 views

htaccess RewriteRule: Premature ending of rewrite iteration?

I'm still trying to grasp the concept of Apache's RewriteRule, so please confirm if my understanding of the below is correct... So, here's a snippet of a website's .htaccess, I add numbers in front ...
1
vote
1answer
77 views

.htaccess rewrite rule domain alias doesn't work

I have a site called: www.example.com this is the main domain. Now I have a Alias: www.example2.com. I want that example2.com will be forwarded to a subdomain of the main domain to ...
1
vote
0answers
56 views

URL rewrite issue with cakephp

I am using cakephp framework 2.2.2 I want to create personalize URL for user if user enter username=pragnesh then they can access my site like http://pragnesh.mylocalhost.com same as in ...
0
votes
3answers
110 views

Always redirecting to https without www

First off all, I have searched and read multiple posts in this form and other websites on this matter and tested everything. Unfortunately the trial and error has not yet payed off. I am OK with ...
2
votes
1answer
46 views

Apache Redirect for Internal Traffic Only

We have a page, gateway.school.edu, where users have to fill out a recaptcha before being directed forward to our password reset. I would like any internal traffic, any user agent on our network with ...
0
votes
1answer
21 views

Trying to rewrite a URL to an existing URL with htaccess

I have a wordpress site up and it's been up for a while. Recently I was asked to change the URL of one of the pages. The current URL is: http://url.com/blog/category/newsroom They want the URL of ...
1
vote
2answers
102 views

Redirect Everything After slash (/) to another directory

I'm sure this is an easy thing to do but I can't seem to find the answer! I'm trying to redirect https://carddav.example.com/MYUSERNAME to ...
3
votes
2answers
85 views

Remove extension from URL using a rewrite without resulting in a redirect loop

On the server, I have a file (on the filesystem) called page.html, which I want to be accessed as site.com/page So if someone goes to site.com/page.html, it should 301 redirect to site.com/page I've ...
0
votes
2answers
26 views

Rewrite cond regex to split an url with a /

I'm struggling to correct the aftereffects a bogus redirect I made which led to a lot of 404s. I need to 301 redirect URLs that look like example.com/xysometext to example.com/xy/sometext ...
3
votes
2answers
509 views

Apache Rewrite Rule non-www to www + http to https + remove trailing slash

I would like to accomplish the following: rewrite non-www to www redirect from http to https remove trailing slash e.g. http://example.co.uk should redirect to https://www.example.co.uk How ...
3
votes
2answers
73 views

non-cachable Canonical redirect of www to non-www

I know this question is debatable for the whole eternity, and most likely nobody knows the real philosophy of this problem. But I'm trying to solve the problem about 301 and 302 response headers in ...
1
vote
1answer
46 views

Rewrite URL with masking from HTTP to HTTPS site (on a different server) are certs needed on first server?

I have a *:80 virtual host in Apache 2.2.15 which is just a bunch of URL rewrites like: ServerAlias foo.bar biz.baz tit.tat RewriteRule / http://somesite.com (R=301,L) ServerAlias differentsite.com ...
0
votes
1answer
58 views

Google can no longer fetch pages after successful URL rewrites using an .htaccess file

I tried to rewrite my URLs so they no longer have the .html extension. But when I did this (successfully) Google can no longer crawl my pages when I use "Fetch as Google". Instead, it returns 404 ...
1
vote
1answer
75 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
110 views

RewriteRule to send all URLs with `mod` in them to the `moderator` directory

I have a .htaccess file in the root directory of my project, that contains all the rewrite rules for the site to functions. Most of these rules belong to the mod section of the site, and only two of ...
2
votes
1answer
160 views

Rewrite up to three folders into three query string parameters to a PHP script

I'd like to use mod_rewrite within the .htaccess file to rewrite folders to a var string. Below is examples of current and what I would prefer. Current URL: example.com/main/folder1/folder2/folder3 ...
0
votes
4answers
43 views

Problem getting rewrite from subdomain to directory to work

I want to redirect demo.example.com to example.com/my-demo. This is my rewrite rule, but I'm not getting it to work on my production server: RewriteCond %{HTTP_HOST} ^demo\.example\.com ...
1
vote
1answer
22 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: ...
0
votes
1answer
26 views

RewriteRule not working at server level?

I wanted to forbid some robots from doing certain things to my websites and decided to add a RewriteRule for that purpose. The rule works when put in one of my <VirtualHost *:80> tag and looks ...
0
votes
2answers
112 views

Mod_Rewrite Error code: ERR_TOO_MANY_REDIRECTS

I know alot people have post about this error , however i still unable to solve it.So that is the reason why i start a new post with it. As stated in the title , i encounter a redirect loop when ...
2
votes
1answer
49 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
2answers
48 views

In 2014 has any SEO value rewriting urls? [duplicate]

In 2014 has any SEO value rewriting urls? If my site consistently links product page, and that product page shows a consistent canonical url, is there a real SEO doing this ...
1
vote
1answer
434 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} ...
1
vote
1answer
68 views

301 redirect + RewriteRule not working together?

I am using a 301 redirect to redirect a page to another page in the same website, which uses RewriteRule to hide the PHP variables in a friendly URL. My redirection code in .htaccess: Redirect 301 ...
2
votes
1answer
69 views

Rehosting content from another server

We have a set of static pages that will augment a customer's existing site. The pages will not reside on the customer's servers for logistical reasons and because we need to maintain control of the ...
1
vote
1answer
40 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 ...
0
votes
0answers
29 views

Apache mod rewrite rules for swapping directories [closed]

I am trying to correct for an issue where some dynamic urls were generated where the downstream directory paths were swapped with what is normal and then the links were published. For example: ...
1
vote
1answer
26 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
2answers
30 views

What is the IIS equivalent of a rewrite rule that sends all requests to a PHP file?

I've always used Apache for all my web development work and I'm struggling to get my head around IIS. I've got an API that re-routes all requests to one particular file: 'api.php', how would I do the ...
1
vote
1answer
539 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... ...
2
votes
4answers
64 views

Redirect example.com:81 to example.com

I need to redirect www.example.com:81/site/ to www.example.com. I have used mod_rewrite a few times, is it possible to solve this in a similar way?
3
votes
1answer
312 views

How to redirect if directory does not exist or should not be seen?

I am using Apache and want to modify my .conf file for a website such that: If the request comes from my IP 1.2.3.4, just display the URL/page as requested If the request is not from my IP and the ...
0
votes
0answers
90 views

HTTPS redirect to HTTP not working with 'www' subdomain

I have 2 rules on my site: one to force the www subdomain, and another to force the HTTP protocol: RewriteEngine On RewriteBase / RewriteCond %{HTTPS} =on RewriteRule ^ ...
2
votes
1answer
38 views

Apache mod_rewrite SSL vs Non-SSL

I have my site setup with two conf files (one for SSL and one for Non-SSL ) The two confs are at this gist -> https://gist.github.com/akinsgre/9645179 The Non-SSL configuration works fine. When ...
0
votes
1answer
590 views

URL rewrite to another folder and file for specific requests

I have following directory structure on my local LAMP: www basic app router.php public index.html .htaccess and I can access my index page with localhost/basic/public/ and I am not using ...
2
votes
1answer
54 views

Geolocalization and Redirection

I have a multilanguage website. My project was to add the Geolocalization so base on the country that open the site to redirect in the specific url with the right language. The structure of the ...
2
votes
1answer
315 views

Changing file extensions in URIs - Server Error after Apache upgrade

Please can anyone help to identify flaw or incompatibility in .htaccess code causing server error? In the process of changing over from static to dynamic website, I had to maintain some static files ...