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

How to match only part of URL and redirect URL with parameters in .htaccess?

I have a number of links with similar structure: example.com/index.php/path/some-path/some-subpath?parameter=1 Which I want to redirect just to example.com/category/ But I want to match only the ...
1
vote
2answers
46 views

How to set preferred domain with https in Google Webmaster Tools

I have registered a website and bought an SSL certificate, installed it and did some mod_rewrite rules to have all my traffic go to https://example.com. So all is working nicely from that perspective. ...
0
votes
0answers
22 views

Moving rewrite rules to virtualhost tags instead of directory tags

Currently, I have my rewrite rules in what I believe is in the Directory context. My relevant part of httpd config file is similar to the following: <virtualhost nnn.nnn.nnn.nnn:port> ...
3
votes
2answers
39 views

How can I use .htaccess to make old link retrieve content from new location?

One of my sites had a WordPress site in the subdirectory (root)/blog/. Using rules in .htaccess, the site was called up without the /blog/ in the URL. I recently changed it by removing the /blog/ ...
0
votes
1answer
18 views

Can rewriterules work without carets or dollar signs?

Currently when I remap my friendly to non-friendly URLs on my website, I normally use lines like these in my .htaccess: RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !^$ RewriteRule .* - [L] ...
2
votes
1answer
58 views

How to redirect a URL without a query string to a URL with a query string?

I've looked around for the answer to my question but only to be confused even more. I'm hoping somebody can help me... I need to redirect this URL: ...
0
votes
1answer
24 views

Did httpd can be rewrite? [closed]

I'm running on Nginx server. I try to rewrite my URL using .htacces file: RewriteEngine On RewriteBase / RewriteRule ^search/(.+)/page=(.+)$ search-results.php?q=$1&page=$2 It give me Internal ...
2
votes
1answer
60 views

How to redirect all that URLs that does not end with “feed” to https?

I want to use Apache's mod_rewrite to redirect all URLs that does not end with /feed to a secure URL (identical, but starting with https), and leave all that ends with /feed unaltered: I want this: ...
2
votes
2answers
39 views

mod_rewrite ignore Stylesheet and JavaScript

I have a mod_rewrite to allow example.com/location as example.com/?page=location RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} !^page RewriteRule ^(.*)/?$ /?page=$1 [L] But how do I ...
3
votes
1answer
63 views

.htaccess syntax multiple RewriteEngine on

I'm learning to maintain my own WP site. After a lot of reading I ended up with my "complete" htaccess file that looks something like this DirectoryIndex index.php # Disable directory listings ...
2
votes
2answers
57 views

How to change whole folder from http to https

The checkout/onepage is working with HTTPS. But, why checkout/cart is not? Here is fragment of the .htaccess: ############################################ ## enable rewrites Options +FollowSymLinks ...
1
vote
3answers
45 views

Regular expression for Apache redirection

In the .htaccess file I would like to redirect (301): From: http://www.example.com/photo<anything> To: http://www.example.com/blog/ Basically, any URL starting with /photo should be redirected ...
0
votes
1answer
14 views

Is a blank really a directory when dealing with mod-rewrite?

I spent about 20 minutes wrapping my head around this, and finally came to a solution but did not know why it worked. The important lines (as it relates to this question) in the apache configuration ...
2
votes
2answers
112 views

Forcing HTTPS and WWW with apache

Apache does not force HTTPS in a subfolder of a folder, but it works in the first level subfolders. Here are all the HTAccess snippets I have tried: RewriteCond %{HTTP:CF-Visitor} '"scheme":"http"' ...
2
votes
2answers
62 views

Redirect to non-www and non-https in htaccess

I need to redirect my WordPress blog from https://www.example.com/blog to http://example.com/blog using the .htaccess file. This is what I have so far: <IfModule mod_rewrite.c> Options ...
1
vote
1answer
40 views

APACHE mod_rewrite add query string to URL

Using mod_rewrite how can I change the current URL format: From: https://example.com/something/NAME-IN-CAPS/phonebook.xml To: https://example.com/anything/whatever/phonebook.php?name=NAME-IN-CAPS
1
vote
1answer
28 views

enable keepalive on apache 301 redirect pages

I want to make it so that every website on the server I manage (including my own website) will enable keep-alive on all (HTTP status 301) redirect pages including ones issued by apache modules. This ...
2
votes
2answers
44 views

Need .htaccess mod_rewrite for serving static content from subdomain, but forcing www otherwise

I have a website where I currently force example.com visits to www.example.com, and it has an SSL certificate, so I also force HTTP to HTTPS. My SSL certificate covers example.com and www.example.com. ...
2
votes
1answer
56 views

After rewriting URL page not found

I want to rewrite my current URL that is http://localhost/sitename/landing-page/?from=Algeria&to=Afghanistan&submit=Submit to http://localhost/sitename/removals-from-Algeria-to-Afghanistan ...
1
vote
1answer
39 views

After mod_rewrite the internal URLs are duplicated many times when crawling

I'm sure it is my mistake in mod_rewrite rules, but I can't seem to figure it out. I've set up the rules for my new site and all works perfect, unless - I try to create a sitemap. The URLs get ...
4
votes
1answer
237 views

redirecting openshift rhcloud domain to custom domain for SEO purposes

Openshift application url: example.rhcloud.com Custom domain: example.com I came across this link and added the redirection rule. However, I can not access example.rhcloud.com now. My custom domain ...
0
votes
1answer
44 views

How do I setup redirect for multiple subdomains to different folders

So I have 2 sites on this particular server and this is all internal, but when a user goes to websvn for instance, I want them to go to websvn.domain.local and it is going there but it is also ...
2
votes
1answer
30 views

Conflicting mod_rewrite rules

The Background I run a university club website which has multiple domains, let's say meow.co.uk, foo.uni.ac.uk/bar/meow/ as two relevant cases. (When I upload files using an FTP client, it's the ...
2
votes
0answers
52 views

What strings do %{HTTP_HOST} and other mod_rewrite variables return? [closed]

If I have a htaccess file that has RewriteCond %{HTTP_HOST} in it, what is the HTTP_HOST? This is something I've been struggling to find out. To help me understand, could you tell me, in each example ...
3
votes
1answer
86 views

A more specific question about a tricky redirect case

me again. :) I will try to keep this more to the point. Synopsis: I am trying to redirect URLs like this: www.desktopscenes.com/Scenes from Yellowstone (2003)/slides/Morning Glory Pool.html to ...
4
votes
1answer
38 views

Need expert help with tricky redirect problem [duplicate]

I actually posted about this years ago, never got anywhere. Did more research, did testing, got something I thought worked and mostly did, but it seems to get bogged down in infinite loops under ...
3
votes
2answers
693 views

htaccess redirect non-www to www with SSL/HTTPS

I want a rewrite rule that redirects everything to https:// AND www. For example https://example.com should be going to https://www.example.com This is what I have: RewriteEngine On RewriteCond ...
1
vote
2answers
404 views

How to change my id and name in php url

How would I change the URL from from: example.com/games.php?id=27 to: website.com/games/271/game-name-here So far I have this in .htaccess: RewriteEngine on RewriteRule ^games/([0-9]+)/?$ ...
0
votes
0answers
31 views

The ultimate recipe to end duplicate content

I decided now its time to fine-tune my apache configuration to finally/hopefully end the duplicate-content madness. I notice the more I pay attention to this, the more income I make from ads. This ...
1
vote
1answer
46 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: ...
5
votes
2answers
160 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
90 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
36 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
79 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
36 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
625 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
17 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
26 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
112 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 ...
2
votes
1answer
93 views

Subdomain htaccess rules

I have the following .htaccess in my root: DirectoryIndex index.html index.php Options +Indexes # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ...
0
votes
1answer
79 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
206 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
248 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
90 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
613 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
126 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
31 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
140 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
29 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
1answer
173 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 ...