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
15 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
21 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
67 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
27 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
53 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
42 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
27 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
102 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
92 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
98 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
65 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
47 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
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
370 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
46 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
43 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
36 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
43 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
78 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
103 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
56 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
141 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
49 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
100 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
108 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
72 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
219 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
151 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
250 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
94 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
48 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
200 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
696 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
400 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
687 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
76 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
266 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
393 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
653 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
63 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
31 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
358 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
189 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
42 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 ...