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

3
votes
1answer
43 views

Redirecting specific URL from HTTPS to HTTP

Long time lurker, first time caller... I have a backend like admin.mysite.com which is able to use HTTPS (has a certificate installed, etc) - but that admin portal is a CMS backend for a number of ...
2
votes
1answer
392 views

Redirect before rewrite

Had an issue where I need to redirect old URLs, but not disable the mod_rewrite for page structure. redirect 301 /home.html http://www.example.com/ It needs to live on the Symphony 2.0 .htaccess ...
2
votes
1answer
403 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 ...
1
vote
1answer
38 views

How to regex a url to redirect user

Using the regex and the .htaccess file, I want to redirect users to a certain URL. I want to redirect: http://www.example.com/* but not http://www.example.com/CDadmin/* I have tried the ...
4
votes
2answers
4k views
3
votes
1answer
40 views

combined 301 redirects not working

I made some changes to the files on a website and now Search Console is showing me 404 errors for some URLs. The normal setup, which works fine is like this: the user-friendly URL ...
3
votes
1answer
30 views

Apache mod_rewrite problem with adding a query string on an internal rewrite

I need to replace /xyz with /index.html?dh=xyz. I use the following config in httpd.conf: RewriteCond %{QUERY_STRING} "!dh" RewriteRule "^/(.*)$" "/index.html?dh=$1" [R] This works perfectly if [R] ...
1
vote
3answers
5k 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
1answer
23 views

RewriteRule RewriteCond

These codes dont work together... How can I integrate both codes? # Block#1 RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.+?)/(\d+)/?$ /search.php?q=$1&p=$2 [L,QSA,NC] RewriteCond ...
4
votes
4answers
2k views

Using env variables with RewriteRule and ErrorDocument

I'm having problems with the following config on my Apache server to Rewrite some URLs. SetEnv PATH_TO_DIR /directory RewriteRule ^%{PATH_TO_DIR}/([a-zA-Z0-9_\-]+)/([a-zA-Z0-9_\-\.]+)/?$ ...
2
votes
1answer
28 views

Apache 2 mod_rewrite Inconsistent Results

My former university, SPSU, was "consolidated" into Kennesaw State University. I used to have the domain bbrown.spsu.edu. As a temporary fix, bbrown.kennesaw.edu was set up by University IT. ...
1
vote
0answers
37 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
59 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 ...
4
votes
3answers
2k 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
0answers
6 views

Passthrough in Virtualhost not preserving the previous URL

I have a RewriteRule written at Apache to redirect to TOMCAT. Passthrough [PT] doesn't seems to work and Getting Bad Request. Same configuration works with [P], but I don't want tomcat PORT to be ...
1
vote
1answer
28 views

htaccess 301 redirect for second level sub directory

I have a directory website with the following URL structure. http://mywebsite.com/information/business-name/ http://mywebsite.com/information/business-name/product-names/ ...
4
votes
1answer
39 views

.htaccess rule fails when including $ at end

The Basic Situation We have a server. It has some static files, some simple, "flat" .php and .html pages, but it also has a WordPress install at the document root, meaning that visiting / takes the ...
0
votes
0answers
38 views

How to add http:// prefix to subdomain redirect in htaccess

I am rewriting a subdomain URL with a query (cart.example.net/ProductDetail.jsp?LISTID=7C0400-1101763508) to a www subdomain (www.example.net/product-category/product). The problem I am facing is the ...
3
votes
1answer
86 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 ...
2
votes
2answers
109 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
0answers
21 views

Strange HTTP:Accept-Language behavior instead of Browser Language Detect [closed]

My qTranslate-X (v3.4.6.4) WordPress (v4.4.2) plugin can't "Detect the language of the browser and redirect accordingly.", so i needed to do a hack by .htaccess. Following solution found in Drupal's ...
3
votes
3answers
185 views

Redirect $.html to $/ mod_rewrite rule clash

I have already remapped URL's from for example /sub/test/ to test.html but I also want to redirect /sub/test.html to /sub/test/ but here seems to be a clash between the rules. .htaccess files is in ...
3
votes
1answer
102 views

.htaccess mod rewrite sub directories redirect loop

I am trying to setup a sub-directory with individual .htaccess. I want to redirect .html files to url without extensions and also add a trailing slash and redirect all non-slashed urls there. Here's ...
3
votes
2answers
40 views

Is a real http to htttps rewrite possible or is this always going to be a redirect?

I noticed that there are some articles on the Internet that talk about using the apache mod_rewrite module to rewrite a client to server http connection to https. But rewrite does all the changes ...
3
votes
1answer
32 views

How do I redirect /search/ to /?s=

I have a typical Wordpress site, with a typical Search page set up which uses the typical GET format <form id="searchform" action="http://example.com" method="get"> <input id="s" ...
3
votes
1answer
31 views

htaccess rewrite incoming links to new one

I'm having a problem with site migration and old links. Now, its not just a server migration, it was also a CMS migration. Site went from umbraco (asp.net) to wordpress. Problem is that google indexed ...
4
votes
1answer
63 views

How do you block a referer but for a specific URL using .htaccess?

I would like to block a referral URL from a specific domain using .htaccess. The link itself must still function on its own, it is only when the incoming referrer matches. My Site Link: ...
1
vote
1answer
125 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. ...
1
vote
0answers
63 views

Rewrite rule is causing a redirect to another host and port rather than showing the content at the current URL

I have a web application working on: next3.info:83 I want to go there with weburen.next3.nl so I used this code: RewriteEngine on RewriteCond %{HTTP_HOST} =weburen.next3.nl RewriteCond ...
2
votes
1answer
25 views

Redirect all pages within subdirectory to new page

After redoing my webshop, I need to redirect every URL within a certain directoy to a new page. All URLs beginning ith example.com/shop/... should be redirected to the page located at ...
2
votes
1answer
10 views

Forcing the removal of query string on a rewrite rule

I find I'm the only one coming up with bizarre behavior on my website. Now one of my extremely important links has malfunctioned. This is the RewriteRule I have that malfunctioned: RewriteRule ^m/?$ ...
3
votes
1answer
65 views

Creating a Combined 301 Redirect in .htaccess

We are being advised by our SEO agency to reduce the number of "chained" redirects we have. So, for example: URL A - http://www.sitename.co.uk/SHOPPING-CATEGORIES/product_name redirects to its https ...
2
votes
1answer
85 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
154 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
91 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. ...
2
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
99 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
57 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> ...
2
votes
2answers
43 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
330 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
369 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 ...
2
votes
1answer
109 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
166 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 ...
0
votes
1answer
33 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
73 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
133 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
637 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
1answer
292 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
5k 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
47 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 ...