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

2
votes
1answer
183 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
vote
0answers
16 views

mod_rewrite cause errors in apache error.log

In Opencart I have enabled SEO URLS, which is working fine, unless that I see errors in apache log: [Thu Apr 16 22:53:38 2015] [error] [client xy] File does not exist: ...
1
vote
1answer
482 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 ...
3
votes
2answers
70 views

htaccess rewrite ignore 2 strings

I have the following rewrite rule to rewrite my old to new URLs: RewriteCond %{REQUEST_URI} !^/activity.*$ [NC] RewriteRule ^(.*)/([0-9]+)/$ /$1/S$2/ [R=301,L] It must also ignore /members, not ...
0
votes
1answer
27 views

Is this a valid redirect-rule return http 301?

I am relaunching a website with over 10'000 pages, must adapt URL a tiny bit and need to be sure my redirect-rules are correct. I simply need to add a "S" before the ID of that particular URL. So ...
1
vote
2answers
99 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 ...
0
votes
1answer
33 views

How can I get a regular expression to only match an empty string? (In a .htaccess file)

I try to make a regular expression in a .htaccess file, that matches only an empty string. I have tried many things, but it seems like it’s impossible. For example, I tried ^$, but it's looking for ...
1
vote
1answer
77 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] ...
2
votes
1answer
359 views

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

I have two domains (here are the actual domain names for simplicity): snapstarr.com fuselog.net I have one hosting account with GoDaddy, for the two domains. the primary domain is snapstarr.com. I ...
1
vote
1answer
30 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
0answers
25 views

Redirect query string URL via .htaccess

I am trying to redirect all query strings to a new URL. Search query example www.example.com/?s=cars to resolve to www.example.com/?search_gcse/?q=cars ("cars" is just an example). What is the ...
0
votes
0answers
10 views

Httpd not rewriting !hostname to hostname [duplicate]

Simple: xxx.xxx.xxx.xxx:443/80 --> https://login.example.com One site, one hostname, one server. So I've done this in the main httpd.conf to avoid virtualhost manips: <Location /> ...
1
vote
1answer
32 views

Problems with apache rewrite

I am running tomcat on centos6. I'm trying to configure Apache as a front end to tomcat so I could access: help-test.example.com:8080/4-3/help help-test.example.com:8080/4-2/help ...
2
votes
1answer
2k views

How do I make SEO friendly URLs from my PHP pages?

I'm pretty new to this and was wondering how to turn my site URLs into SEO friendly URLs using .htaccess and mod_rewrite? My URLs take the form mydomain.com/index.php?pid=1&pagename=Some Page I ...
1
vote
2answers
48 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 ...
3
votes
1answer
203 views

Hiding folders inside root folder using htaccess

In my server I have the following folder structure and I want to display each folder project link without the folder name. How can I do this? Root Folder -> Subfolder1 -> Project folder ...
2
votes
1answer
29 views

Trying to add cache header to 301 pages made by ModRewrite

I have several URLs on my website that get redirected to other URLs using Mod-Rewrite. For example: RewriteRule ^section$ /newsection [NC,L,R=301] The above rule redirects ...
2
votes
1answer
37 views

Redirect a subdirectory to the main domain in htaccess

I have the folowing structure: www.example.com - DE version www.example.com/de - DE version www.example.com/en - EN version I want to be like that: www.example.com - DE version ...
0
votes
0answers
13 views

Using mod_rewrite to set cookie and modify domain name

I have two editions of a website. The mobile and desktop version. All desktop sections of the website have normal urls and mobile sections have subdomain urls suffixed with the word mobile. Example: ...
0
votes
0answers
11 views

Minimalist RewriteRules but access directories, error pages, etc statically

I am fairly experienced with PHP, but am new to Python. I am generally familiar with mod_rewrite, though I still get mystified by it very often. I am now trying to write a new Python web application ...
1
vote
0answers
26 views

Using .htaccess rewrite rule that doesn't run for specific folders and files

I want to create a .htaccess file that reads index/somepage as index.php?q=somepage. This is how far I got: Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} ...
0
votes
0answers
42 views

How to allow access to subdirectory in website using htaccess?

I am wanting to create a seperate directory for my analytics program to function. My website is www.loosebruce.co.uk and I want my directory to be accessible as www.loosebruce.co.uk/analytics The ...
0
votes
0answers
39 views

How can I change rewrite base using .htaccess, from my root directory to a folder?

My issue here is that I have a folder called "project" on my server, for a cms that I use. However when I click on a link in that file for example about.html, it loads a file outside the folder on the ...
0
votes
0answers
12 views
3
votes
1answer
48 views

Mod-Rewrite content negotiation for mixed Accept header?

I am configuring a lightweight content negotiation mechanism using Apaches's Mod-Rewrite. The configuration should deliver several different data representations (for instance, HTML, XML, RDF/XML, and ...
1
vote
0answers
114 views

Convertion of htaccess rewrite rule to nginx [closed]

Through searching the internet with "converting htaccess to nginx rule" I came up with anilcetin and winginx .htaccess to nginx converter which I doubt it doesn't correctly output what I need. Which ...
1
vote
0answers
34 views

Configuring subdomain on Apache2 as an alias for subfolder [closed]

If I try to access my ownCloud service under home.example.com/owncloud/ it's working. I'm able to set the mod_rewrite rule to access the same service under cloud.example.com which is a CNAME for ...
-1
votes
0answers
17 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 ...
5
votes
2answers
5k 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 ...
2
votes
1answer
68 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
71 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
2answers
387 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 ...
4
votes
2answers
308 views

Redirect non-www to www while preserving protocol

I am aware of the fact that there are tons of questions in this section and in server fault dealing with re-directions from non-www to www URLs. But I couldn't find one dealing with this issue while ...
2
votes
1answer
58 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 ...
0
votes
2answers
65 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 ...
1
vote
0answers
129 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 ...
1
vote
1answer
190 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
2answers
2k 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
2answers
579 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 ...
2
votes
1answer
64 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
42 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: ...
2
votes
2answers
324 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 ...
2
votes
1answer
63 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 ...
4
votes
2answers
3k views

How to write a generic .htaccess file rule, regarding RewriteBase

The following rule in my .htaccess works just fine for routing calls to index.php: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] However, this does not ...
1
vote
1answer
58 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
191 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
252 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
401 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
2answers
600 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
54 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 ...