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

0
votes
1answer
120 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 ...
-1
votes
0answers
16 views

Error Using htaccess

I am using Wordpress site .When We change the permalink to postname the htaccess will be changed so they go to the plain code RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f ...
1
vote
1answer
407 views

Using mod_speling with multi-level htaccess and rewriterules

We recently switched formats for managing our 301s. For the most part, everything went well, but it seems to have stopped mod_speling from working properly. Here's what we changed: old ...
2
votes
2answers
214 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
47 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 ...
1
vote
2answers
40 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 ...
2
votes
2answers
269 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 ...
2
votes
1answer
141 views

Is it possible to check the case on Apache redirects or aliases?

I have a big website (15,000 pages) with a log list of redirects (about 800) that have been used in marketing pieces for years. My Apache server has been running mod_rewrite for the past 10 years or ...
5
votes
3answers
18k views

How to remove trailing slashes from URL with .htaccess?

The situation Across the entire domain, we'd like the URLs to hide file extensions and remove trailing slashes, independent of the domain name itself (as in, works on any domain). Sample of our ...
7
votes
1answer
1k views

.htaccess redirect url without trailing slashes

In my htaccess I have some rewrited urls like these: RewriteRule ^first-page$ /subdir/page.php?id_page=1 [QSA,L] RewriteRule ^second-page$ /subdir/page.php?id_page=2 [QSA,L] RewriteRule ^third-page$ ...
3
votes
2answers
50 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
4answers
36 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
34 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 ...
3
votes
2answers
46 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 ...
3
votes
2answers
140 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
1answer
47 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
138 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} ...
0
votes
2answers
17 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 ...
1
vote
1answer
6k 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
27 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
142 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... ...
0
votes
1answer
51 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 ...
3
votes
1answer
289 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 ...
1
vote
0answers
129 views

Apache, Rewrite Rule and Directories

I'm using the current virtual host: <VirtualHost *:80> ServerAdmin webmaster@mysite ServerName example.co.uk ServerAlias www.example.co.uk DocumentRoot ...
2
votes
1answer
284 views

.htaccess rewrite , parked domain on another site to read the proper domain name

I have a parked domain example.co.uk on another domain name web-space in a folder and need to rewrite the domain name in the browser URL as it currently shows the other domain name while browsing and ...
1
vote
1answer
82 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
48 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 ...
2
votes
1answer
631 views

Apache htaccess results in files being downloaded instead of displayed

So I had this "beautiful" website that did exactly what I wanted it to do. Then I shut down my PC, reboot and...the pages just download now instead of being displayed. I re-installed XAMPP and ...
1
vote
3answers
3k views

“File does not exist” in Apache error log when mod_rewrite is using

I am getting below error in server log, when re-writing the URLs. [Fri Jan 25 11:32:57 2013] [error] [client ***IP***] File does not exist: ...
1
vote
1answer
21 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 ...
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?
0
votes
2answers
61 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
32 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 ...
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
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 ...
1
vote
1answer
33 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 ...
0
votes
0answers
27 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: ...
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
2answers
950 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 ...
0
votes
0answers
70 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 ^ ...
0
votes
1answer
260 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
164 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
1answer
88 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 ...
2
votes
1answer
196 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
531 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 ...
4
votes
1answer
79 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 ...
1
vote
1answer
28 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, ...