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
56 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: ...
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 ...
1
vote
1answer
24 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
43 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. ...
1
vote
1answer
75 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. ...
3
votes
3answers
1k views

Replace %26 in htaccess to %2526

I would like htaccess to rewrite example.com/something_%26_else into example.com/something_%2526_else I'm importing a bunch of pages that have ampersands in the title from MediaWiki. These are ...
1
vote
3answers
97 views

Simplify URL rewrites in .htaccess?

RewriteRule ^([A-Za-z0-9_\-]+)$ /userviewproducts.php?category=$1 [L] RewriteRule ^([A-Za-z0-9_\-]+)/$ /userviewproducts.php?category=$1 [L] RewriteRule ^([A-Za-z0-9_\-]+/[A-Za-z0-9_\-]+)$ ...
0
votes
0answers
21 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
38 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/ ...
1
vote
2answers
295 views

htaccess rewrite doesn't work

I'm trying to redirect url's in my /joomla/ folder containing "rsform" to the same url but except for /joomla/ /formulieren/. However my tried .htaccess rewrite doesn't work. I tried: RewriteEngine ...
2
votes
1answer
308 views

HTACCESS redirect a URL with query string in it

Basically you can visit /stats.php?player=name by simply typing in https://domain.com/@name and it works perfectly. But I also need the old /stats.php?player=name links to redirect to ...
3
votes
2answers
660 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 ...
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 ...
1
vote
1answer
149 views

Rewrite Rule for Manipulating Query parameter - middle value in long Query Value

Trying to achieve Source - https://rrr.rrr.com/us/Product-Family/Products/c/Products/layout?layoutType=false&page=0&grid=true&q=:relevance:DriveType:Flash:ProductFamily:Prd 1 To ...
1
vote
1answer
242 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
17 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
2answers
72 views

Rewrite everything that is not a file

I want to have everything that looks like this: /1/2/3/4/5/[...] to redirect to this: /index.php?u=/1/2/3/4/5/[...] unless the requested string is a specific file. So anything that doesn't have ...
1
vote
1answer
111 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 ...
3
votes
1answer
591 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
1answer
50 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 ...
3
votes
1answer
282 views

URL rewrite from www.example.com/subdirectory to example.com/subdirectory

I need a solution for the following problem: I use a CMS and want the backend to only be available at http://example.com/backend and not at http://www.example.com/backend. The rest of the site should ...
8
votes
4answers
4k views

Forcing SSL and www in .htaccess

I'm looking for a way to force SSL and www. I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a URL in this format: ...
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
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 ...
4
votes
4answers
3k views

How to create .htaccess to block access to a subdirectory that hosts a separate domain

I have a main domain (me.com) and I am hosting files for my mom's website (mom.com) in a subdirectory in my public_html folder so that mom.com uses files from me.com/mom. All I want to do is make it ...
1
vote
1answer
140 views

How do I get rid of the “www” with mod_rewrite?

I want to get rid of the "www" in front of my domain, and I'm trying the following, but it's not working: RewriteEngine On RewriteCond %{HTTP_POST} ^www\.example\.com [NC] RewriteRule ^/(.*) ...
1
vote
2answers
375 views

Mod_Rewrite Error code: ERR_TOO_MANY_REDIRECTS

As stated in the title, I encounter a redirect loop when accessing my pages in the website. Here is my rewrite config. RewriteCond %{HTTP_REFERER} ^http://example\.com/test/store\.do [NC] ...
2
votes
1answer
117 views

.htaccess redirect with mod_rewrite

I moved my wiki from http://jklatex.square7.de/wiki/doku.php/start to http://logicpuzzle.square7.de/start and now i want to redirect the URL with mod_rewrite. My .htaccess is as follows: # ...
2
votes
2answers
38 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 ...
6
votes
1answer
958 views

How to internally rewrite a page when requested from specific HTTP_HOST

I have a Drupal site, example.com, and our client has a campaign that they're promoting for which they've bought a new domain name, campaign.com. I'd like it so that a request for campaign.com ...
2
votes
1answer
59 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
153 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 ...
2
votes
1answer
66 views

mod_rewrite change . (dot) to - (hyphen)

I'm moving my site and the URL structure has changed because of the new CMS. The old URLs are similar to /my.products.htm, but on the new site we are changing the URLs to /my-products. Is there a way ...
2
votes
2answers
167 views

Is it possible to mod_rewrite BASED on the existence of a file/directory and uniqueID?

My site currently forces all non-www. pages to use www. Ultimately, I am able to handle all unique subdomains and parse correctly but I am trying to achieve the following (ideally with mod_rewrite): ...
1
vote
2answers
114 views

Rewrite URLs to add a slash

I know how to rewrite URLs to redirect to a page. When the / is not at the end of www.example.com/user/myUserName the redirect works: RewriteRule /$ /user/index.php When I write RewriteBase / the ...
2
votes
3answers
300 views

Mod Rewrite question

Is there a way to rewrite http://localhost/embed/player.swf?file=http://www.youtube.com/watch?v=7yKDhm4_-90 to something smaller? or is there a way to change this into ...
1
vote
1answer
288 views

How to block access to a sub-site with mod_rewrite?

Let's say I have the sites siteA.com and siteB.com. They are hosted such that siteB.com actually points to siteA.com/siteB. How can I block someone from visiting siteA.com/siteB using mod_rewrite? ...
3
votes
1answer
58 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 ...
1
vote
1answer
169 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 ...
2
votes
2answers
56 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 ...
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
110 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"' ...
1
vote
1answer
63 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
2answers
59 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
39 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
2
votes
2answers
41 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
2answers
103 views

How to make mod_rewrite work transparently?

Following is the content of .htaccess file <IfModule mod_rewrite.c> Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ...
0
votes
1answer
2k views

Mod Rewrite not working

I am trying to get the URL www.example.com/blogs/<displaynamehere> to show what is in the directory at www.example.com/blogs/blog.php$display=<displaynamehere> So thanks to the people ...
1
vote
1answer
463 views

How can I set my site root from: localhost/mysite/ to: localhost/mysite/view/ via htaccess

hi just wondering if this is possible, when you access my default site directory localhost/mysite I want to set the path to render localhost/mysite/view/ all my HTML pages will be rendered here just ...
4
votes
1answer
102 views

What's the “^” in RewriteRule Statements?

I keep seeing the ^ character in RewriteRule statements in a context that doesn't fit with the usage specified in this document about regular expressions. For example: RewriteRule ^(.*)$ $1.php ...