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

Apache .htaccess mod_rewrite: use of [NC]

I see tons of .htacces examples containing the [NC] flag (NoCase = case-insensitive) For example the famous h5bp page use the [NC] flag a lot: ...
2
votes
2answers
44 views

Redirect non-www to www : .htaccess without giving the domain name

To redirect non-www to www we often see this in .htaccess: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule ^(.*) http://www.example.com/%{REQUEST_URI} ...
1
vote
1answer
23 views

How to do 301 redirect for complete URL?

I have a lot of URL, which can't be redirected, or, better, rewrited with mod_rewrite in .htaccess, so instead rewriting, I have created 301 redirects manually. It isn't too much records, about 40 ...
0
votes
0answers
21 views

Hosting htaccess redirect subdirectory to subdomain

I have simple hosting plan with domains included: Now I have the domain.com and seconddomain.com now I want to use all that domain and give them his own root directory. If I use the controle panel ...
1
vote
1answer
19 views

Apache 2.2 Not Identifying Safari with HTTP_USER_AGENT

I have a web server that has to meet PCI compliance requirements. Their latest round of policy changes have removed support for Safari, after having removed support for Windows XP based IE clients. ...
0
votes
1answer
18 views

Do we have any redirect solution for all of subURL?

Suppose I redirect exmpale0.com to example1.com , example1.com is newer. Already , I promoted my exmpale0.com into social networks , Suppose I had: http://example0.com/blahblah Now I have ...
3
votes
2answers
109 views

redirect 204 with htaccess if url contain certain string

I get tons of url with "undefined" added at the end of url, consisting about 20% of my pageview. I tried to check the troubling script source and can't find it. Tried some solutions but none of them ...
0
votes
1answer
16 views

stopping accessibility of internal script files via mod_rewrite

Turns out after researching, one site found duplicate content on my website. The reason is because the unfriendly php file that friendly URLs link to was apparently discovered by a robot and then got ...
1
vote
0answers
23 views

Using mod_rewrite to force users to use our caching proxy

During a recent audit we became aware of several users who have not set their DNS records to correctly point to our name servers. Since we don't control the domain names of our users directly, we're ...
1
vote
1answer
71 views

Efficient use of 301 for large redirect map

EDIT: As requested below, this is the entire ruleset for one product (obsolete now, as I should be able to consolidate these into ONE simple rule that looks for the productID#): RewriteRule ...
0
votes
1answer
36 views

How to mod_rewrite url with subdomain and change extension

I need to change the pattern of my url from the normal path into a subdomain. I tried write the .htaccess but it's not work. http://hello.com/sos/article.php?id=1&title=this-is-a-title.php From ...
1
vote
1answer
81 views

htaccess condition if the first subfolder exists

I believe I want to know how to detect whether the first subdirectory in a request is valid. I am wanting to deploy several different versions of the same web application into different directories ...
1
vote
1answer
64 views

Apache htaccess - modify query string with mod_rewrite

I've recently changed scripting on my website, and this has resulted in a few 404 errors as some very old queries are no longer being redirected correctly. I've been trying to create a rewrite rule ...
0
votes
1answer
31 views

IP-based redirection using mod_rewrite

I'm running a small VPN server where each user has his own static IP. I set up an Apache server in order to host files for each of them and instead of using a new registration system, I wanted to take ...
2
votes
1answer
181 views

Returning 404 error after using RewriteRule on localhost

I would like to use localhost/projects/project1/page/x instead of localhost/projects/project1/index.php?page=x. But after I had redirected the URL in .htaccess using RewriteRule, it returned my 404 ...
2
votes
2answers
99 views

What is .htaccess rewrite rule for humans.txt in the query string?

From http://www.allthingsdemocrat.com/block-bad-bots-in-htaccess.txt: <IfModule mod_rewrite.c> RewriteCond %{QUERY_STRING} http\:\/\/www\.google\.com\/humans\.txt\? [NC] RewriteRule .* - [F,L] ...
1
vote
0answers
26 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: ...
3
votes
2answers
110 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
28 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 ...
0
votes
1answer
82 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
0answers
66 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
11 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
40 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 ...
3
votes
1answer
399 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
48 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
47 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
50 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
14 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
50 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
87 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
118 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
13 views

URL rewriting removing multiple url variables and replace them with slash [duplicate]

How can I rewrite my URL from index.php?m=feb&p=news to index.php/feb/news
3
votes
1answer
63 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
151 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
62 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 ...
2
votes
1answer
118 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
125 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
73 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
225 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
159 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
434 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
113 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
49 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
2answers
274 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
735 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
406 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 ...
2
votes
1answer
808 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
81 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
284 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 ...