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

3
votes
2answers
34 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
16 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
118 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 ...
2
votes
2answers
40 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
37 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
0answers
29 views

htaccess Rewrite changes the URL which I don't want [on hold]

I use this rewrite rule at my local Apache server: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^ellada\/(.*) public/index.php/$1 [L,QSA,NC] RewriteCond %{REQUEST_FILENAME} !-f ...
0
votes
1answer
49 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
25 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
80 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
45 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
34 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
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: ...
0
votes
1answer
14 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
58 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 ...
1
vote
1answer
33 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
42 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
105 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
54 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
45 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
32 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
25 views

Apache mod rewrite rules for swapping directories

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

Apache/ISS equivalent

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
121 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
63 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
276 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
64 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
28 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
221 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 ...
1
vote
1answer
45 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
179 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 ...
5
votes
2answers
528 views

I am changing my file extensions in URLs, how to keep my good SEO results?

We have a website with good SEO results. For design reasons I have to update the design and I have to change file names from .html to .php. But I keep my domain name! What should I do in order to ...
2
votes
1answer
245 views

Using .htaccess, can you hide the true URL?

So I have a web hotel with 1 main website http://www.myrootsite.com/ and a few websites in subdirectories, in a folder called projects. I have domain names pointing to the subdirectories, but ...
1
vote
1answer
26 views

Proper syntax for .htaccess Rewrite

I'm very new at this so apologies if this is too easy, but would this be proper syntax for redirecting an entire site to a new domain? This is what was suggested so my other concern is blank lines, ...
4
votes
1answer
78 views

Is there any difference, from Google's point of view, on the method used for a 301 redirect?

I have a website with an extremely good Google rank for it's particular niche. I've rebranded and need to redirect to a new URL. In the eyes of Google, what's the difference, if any, between the ...
0
votes
1answer
20 views

How can I rewrite to my .htaccess in PHP? [duplicate]

How to rewrite my URL from http://www.mysite.com/listingsecond.php?ID=1 to http://www.mysite.com/listingsecond? How can I rewrite to my .htaccess in PHP to do this?
1
vote
2answers
100 views

IP, and page-specific redirect?

I'm trying to send a particular IP, that is trying to get one page on my site, to another page, and do this through my .htaccess file. I've seen many general descriptions of how to do it (in many ...
0
votes
0answers
262 views

SocialEngine 4.5 redirect loop problem

I am installing SocialEngine 4.5. Here is the .htaccess file in the first level of the SocialEngine /public_html/social_engine2/ directory: # $Id: .htaccess 7539 2010-10-04 04:41:38Z john $ ...
2
votes
2answers
198 views

Error 404 after rewrite query strings with htaccess

I'm trying to redirect the URLs of a client's website like this: www.localsite.com/immobile.php?id_immobile=24 In something like this: www.localsite.com/immobile/24.php I'm using this rule in ...
1
vote
1answer
95 views

What is occurring in this .htaccess file in regards to rewriting to clean URLs?

I have the following code in my .htaccess file, which is working fine and using "pretty" permalinks to reroute everything back to /index.php, and using $_GET values to serve customized content based ...
1
vote
1answer
42 views

Changing www to point to non-www, instead of the opposite, using .htaccess

I'm switching servers and need to change the following RewriteCond and RewriteRule commands in the .htaccess file. Right now I'm pointing domain.com to www.domain.com using: RewriteCond %{HTTP_HOST} ...
1
vote
1answer
149 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 ...
0
votes
1answer
142 views

How to secretly rewrite Google Analytics campaign codes to main page?

I want to create a simple "secret" mod_rewrite redirect (not shown in user's browser address box) to redirect: http://www.mydomain.com/code -> ...
1
vote
2answers
873 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 ...
2
votes
1answer
155 views

Apache rewrite rule to add a directory in front of a file

I have an HTML page in my root directory, and when someone clicks it I'd like there to be a directory before the file name, that doesn't exist. For example, instead of just being able to access: ...
1
vote
0answers
45 views

Two stage Apache rewrite not working

I had a list of "Redirect permanent path/to/url1 http--//domain2.com/path/to/url2" rules working as a test, but when I attempted to couple them with mod_rewrite rules to catch non-matching domain1 url ...
1
vote
1answer
114 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: ...
3
votes
1answer
785 views

Using .htaccess to set a cookie and 301 redirect

I currently have in my .htaccess: RewriteRule ^$ http://chfmaine.com/ [CO=moved:yes:chfmaine.com:1/,R=301,NE,NC,L] I was basing this off of this post. That's a lot more than I need but the setting ...
2
votes
1answer
352 views

Rewrite rule not working for redirect in subdomain hosted in a subdirectory of the main site [closed]

I am running a WordPress network. This means there are multiple websites produced by one installation of WordPress. Each website is a subdomain of the parent website. WordPress handles the creation ...
0
votes
1answer
110 views

URL rewrite from www.domain.com/sudirectory to http://domain.com/subdirectory

I need a solution for the following problem: I use a CMS and want the backend only be available at http://domain.com/backend and not at http://www.domain.com/backend. How do I have to change my ...