Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
4 votes
1 answer
120 views

Case insensitivity for Cyrillic characters in Apache .htaccess RegEx does not work

Consider the following RewriteRules: RewriteEngline On RewriteRule ^services$ services.php RewriteRule ^новости$ news.php What they achieve is that www.example.com/services loads the content of ...
plsssineedheeeelp's user avatar
1 vote
1 answer
1k views

Redirect all URLs ending in ".-detail" to remove the dot

I have a rather odd situation where our old URLs are ending in .-detail and need changing to just -detail. For example: example.com/product.-detail needs changing to example.com/product-detail In ...
markbarabus's user avatar
1 vote
1 answer
395 views

.htaccess redirect if param value not portuguese-pt (FORCE WHMCS ONLY ONE LANG)

I need help to redirect URLs with multiple language codes to one with .htaccess. The following URLs should redirect: https://example.com/cp/cart.php?a=add&pid=7&language=us https://example....
Pouyan Danesh's user avatar
2 votes
1 answer
409 views

Caret within parenthesis in RewriteRule

What does this mean: RewriteRule "(^|/)\." - [F] I know the F flag means to throw a 403 forbidden error. And I know the escaped period means that directories starting with a period are forbidden. ...
arnoldbird's user avatar
2 votes
0 answers
48 views

RewriteRules for .htaccess [duplicate]

This question has an accepted answer at Stackoverflow I have a PHP file named as otp.php. When URL in the URL bar is http://localhost/college/otp/MTA=/teacher It should be treated as http://...
paran's user avatar
  • 31
1 vote
1 answer
173 views

htaccess rule to encode only some captured group

My current rule is RewriteRule ^data/(v[0-9]\.[0-9]\.?[0-9]?)/.*$ http://35.231.131.100:5000/cocoon_$1?subject=https://w3id.org/cocoon/$0 [L,NE,QSA,R=308] It will convert https://w3id.org/cocoon/...
Mzq's user avatar
  • 123
2 votes
1 answer
522 views

Apache Redirect based on directory match & Add another letter to the destination URL

So here’s what I’m trying to accomplish. I have this link, I want to 301 redirect: Origin URL: https://www.example.com/folder1/page.aspx?fh_location=%2f%2fpackages%2fnl_BE%2fpr_earlybookable%3E%7b0%...
Ja Hi's user avatar
  • 23
0 votes
1 answer
117 views

Apache .htaccess: do not redirect if

I'm struggling to find out how to perform the following redirection via .htaccess and it's driving me a bit crazy. Scenario: If requests points to one of the following paths, do not perform any ...
jrance's user avatar
  • 1
1 vote
0 answers
2k views

Decode URL Query String using Mod Rewrite / Regex

I have the following encoded URL https://example.com/external-image?url=http%3A%2F%2Fwww.thirdpartydomain.com%2FTWM%2FImages%2F1264%2F143242%2FFull%2F2201625016119496.jpg I'm using mod rewrite to ...
codejunkie's user avatar
2 votes
1 answer
2k views

mod_rewrite with multiple QUERY STRINGS

This is an extension to my question https://serverfault.com/a/761474/77231 I am trying to add an additional QUERY STRING parameter to the URL and change spaces to underscores but am having no success....
TryTryAgain's user avatar
  • 1,162
0 votes
1 answer
1k views

Implement apache equivalent mod_rewrite functionality in lighttpd

Here's the mod_rewrite .htaccess file which is meant to work on Apache Servers for my web-app RewriteEngine On RewriteBase /cs200/tokens/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{...
Titanoboa's user avatar
  • 101
7 votes
1 answer
15k views

url rewrite, nginx throw 404 errors, nothing in error logs

below rewrite works fine: rewrite ^/city/restaurants$ /city/listings/restaurants permanent; but this doesnt work rewrite ^/city/restaurants$ /city/listings/restaurants last; rewrite ^/city/...
Olaf Stavenger's user avatar
1 vote
0 answers
57 views

Apache rewrite not finding path

I am trying to rewrite an internal path for specific requests. I have the following URL: http://192.168.0.100/iw/cci/meta/no-injection/iw-mount/default/main/intranet/infozone/pab/WORKAREA/content/...
markbernard's user avatar
1 vote
0 answers
207 views

Apache2 mod_rewrite, handling the optional "/" at the end of a URL

I am attempting to host a single custom page to set as my homepage on my server. The real path to the page is example.com/start.html. However, I do not want this ugly URL in my homepage so I am ...
Christian's user avatar
  • 111
1 vote
2 answers
7k views

apache - query string rewrite rule appends condition to URL

In trying to rewrite site-search.html?searchword=search%20term as advanced-search#q=search%20term I always end up with advanced-search#q=%3Fsearchword%3search%20term The %3Fsearchword%3 ...
manchine's user avatar
1 vote
2 answers
1k views

apache - query string rewrite rule adds percentage symbol

I've set up a rule to rewrite a query string. Although the redirection is correctly performed, a % character is appended to the rewritten query portion of the URL, like so: index.php?option=...
manchine's user avatar
1 vote
1 answer
69 views

Rewrite rule when source contains a '?' [duplicate]

Scratching my head on this. I have an old URL: http://myserver/blog/archive?openview&type=Category&key=Demo and a new URL http://myserver/blog/categories/Demo I'm trying to get a ...
stwissel's user avatar
  • 680
0 votes
0 answers
49 views

mod_rewrite rule should be matching, but isn't [duplicate]

I've only started editing rewrite rules a few days ago, before now I'd copy and paste them for each case. I've written a rule which as far as I can tell*, should be matching but isn't RewriteRule ^/...
Jamie Taylor's user avatar
3 votes
1 answer
2k views

How to block all incoming proxy visits except from one specific I.P?

I have a page that is prone to attacks, so, in order to reduce the anonymous attacks, I use this code in my .htaccess which I found online : # BLOCK PROXY VISITS <IfModule mod_rewrite.c> ...
user avatar
1 vote
1 answer
165 views

Mod_Rewrite Rule (or an Alternative) For Reorganizing Directory Structure [closed]

The website I work on had these two pages in the past: http://www.africananimals.com/stripes/zebras and http://www.africananimals.com/news/zebras (These are not actual domain names, just examples.)...
Dimitri Vorontzov's user avatar
1 vote
2 answers
2k views

How to combine RewriteRule of index.php and queries rewrite and avoid Server Error 404?

Both RewriteRule's works fine, except when used together. 1.Remove all queries except query ?callback=.*: # /api?callback=foo has no rewrite # /whatever?whatever=foo has 301 redirect /...
Binyamin's user avatar
  • 143
2 votes
1 answer
2k views

Convert from apache rewrite to nginx

I want to convert from apache rewrite modules to nginx RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] RewriteCond %{...
Linux Intel's user avatar
1 vote
1 answer
2k views

How to match a string in URI with regular expression? [duplicate]

In my Apache config httpd.conf, I wish to setup a rule like below SetEnvIfNoCase %{QUERY_STRING} ^.*(getBook+)$ no-gzip dont-vary I am hoping to do no-gzip when my URL looks like http://myurl.fake....
forestclown's user avatar
1 vote
3 answers
2k views

Apache mod_rewrite, multiple variables

I'm struggling a bit with mod_rewrite and replacing multiple variables with regexes. I'm trying to rewrite the following: www.mysite.com/avatars/funny/1 into: www.mysite.com/avatars.php?genre=funny&...
user745595's user avatar
1 vote
1 answer
1k views

Apache RewriteCond: inject string into URI between regex match groups

EDIT This works, needed to use % in place of $ for capture groups: RewriteRule (.*) http://localhost:8081/%1/%{TIME_YEAR}1101%2 [P] Having a hard time sorting this out. Need a date string ...
virtualeyes's user avatar
1 vote
1 answer
720 views

RewriteRule mp3 to php

I want to rewrite all .mp3 files to a php file. And I dont want to pass on the path so http://localhost/somepath/feb.mp3 http://localhost/feb.mp3 shouldn't do any difference. I came up with: ...
Oldek's user avatar
  • 111
0 votes
1 answer
2k views

Mod_rewrite excluding files/directories but including .php files

The traditional mod_rewrite for routing is as follows: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L] However ...
M1ke's user avatar
  • 175
0 votes
1 answer
266 views

.htaccess ModRewrite when moving web root content into subdirectories?

I'm cleaning up and rearranging the files on my server (basic shared hosting situation) and am digging into .htaccess to do so. I'm moving the content I had in my web root into the subdirectory of /...
user avatar
1 vote
1 answer
2k views

RewriteRule: cannot compile regular expression. Version support?

I'm running an Ubuntu 10.04 LTS, Apache version 2.2.14. On httpd.conf I've a rewrite rule that look like this: RewriteRule (*UTF8)^/users/([^/])([^/]+)/(.*)$ /users/$1/$2/$1$2/$3 [L] The idea ...
koby's user avatar
  • 111
1 vote
1 answer
2k views

Apache htaccess RewriteRule to remove trailing slash; infinite loop?

I use the following in .htaccess (mod_rewrite) to remove the trailing slash from my URLs: RewriteRule ^([a-z0-9_-]+)/$ $1 [L,NC,R=301] Of course, since the character class doesn't match a slash, ...
Chris Poole's user avatar
0 votes
2 answers
1k views

need to redirect to static url based off of string patter match in uri

I have siteminder protecting an Oracle ADF java faces app. It appears I am going to have to intercept an http reqeust for the logout link delivered by Oracle in order to kill the siteminder session. ...
organicit's user avatar
  • 115
0 votes
2 answers
136 views

Optimal mod_rewrite regex. Does the way the matching patterns are arranged inside the regex matter?

I have the following: RewriteRule ([a-zA-Z0-9]{5})?/load_page/([0-9]+) Which arrangement would be optimal for the regex: RewriteRule ^/([a-zA-Z0-9]{5})?/load_page/([0-9]+) OR RewriteRule ^/...
Catalin's user avatar
0 votes
1 answer
61 views

Help with simple mod_rewrite needed

My site uses mod_rewrite for most URL's within the site. eg. domain.com/contact.htm domain.com/product/details.htm I've had domain.com/contact.htm working for a long time and is quite simple, but ...
user avatar
3 votes
2 answers
6k views

apache question mark RewriteRule question

So i am trying to redirect from index.php?action=search&query=search text goes here to search?query=search text goes here i tried this so far but with no luck RewriteRule ^search/? index.php?...
stergosz's user avatar
  • 129
1 vote
1 answer
268 views

htaccess for wildcard subdomains

How to translate the example URL to the needed one? From http://test.at.domain.com To http://domain.com/at/index.php?at=test I have: RewriteEngine on RewriteCond %{HTTP_HOST} (\w+).at.domain.com ...
luis's user avatar
  • 111
4 votes
2 answers
946 views

Why does a $1 backreference work in a rewrite with no subgroups?

Someone I'm working with committed a RewriteRule such as the following to SVN: RewriteRule ^admin/ebay.*$ /yii.php/$1 [L] I warned him that it may not work because there is no subgroup in the match ...
Ezekiel Victor's user avatar
2 votes
2 answers
739 views

URL rewrite on custom Wordpress site

I've been tasked with modifying an existing Wordpress site with URL rewriting. Problem is I've never done this before. I know these rules should go in a .htaccess file in root with something like this ...
o01's user avatar
  • 249
1 vote
2 answers
562 views

Why do two patterns (/.*) and (.*) match different strings?

Shouldn't the two patterns (/.*) and (.*) match the same string? My real question is actually: where did the "abc" go? Something funky seems to be happening inside the mod_rewrite engine... Given ...
Leftium's user avatar
  • 303
0 votes
1 answer
1k views

(\d+) and ([0-9]+) htaccess rewrite not working on new server, works fine on old server

RewriteRule ^mp3/(\d+)/(.*)/$ download.php?id=$1 [L,NC] is the specific rewrite rule I am trying to get working....it was working fine on my old server but now I am on a server with Apache 1.3.4.1 ...
Ian's user avatar
  • 1
1 vote
2 answers
346 views

mod_rewrite rule

I need a mod_rewrite rule that sends all requests to index.php unless the request is for anything in the /media/ folder. I have a similar rule for lighttpd but I don't know enough about regex/...
bufferoverflow's user avatar
2 votes
2 answers
180 views

Make shortened and long urls play together on the same domain (RewriteRule)

Long story short, I want to have both example.com/aJ5 and example.com/any-other-url working together. I'm using apache and not very good at writing regex. I have already a global RewriteRule which ...
Renato Renato's user avatar
0 votes
1 answer
134 views

Need a Mod rewrite regex solution for .htaccess

I moved my site to different server since then my all urls started showing up 404 error. earlier my all urls were like this mysite.com/title-of-url but now all such urls are getting 404 error, so i ...
user avatar
1 vote
1 answer
2k views

mod_rewrite rule for images with query string

I'm a mod_rewrite novice and a regex noob, but here's what I want to do: I've got a script that will re-size images on the fly. I'd like to be able to take any image file path, add a query string to ...
Bryan M.'s user avatar
  • 161
2 votes
1 answer
2k views

how to use a rewrite rule to test the date in a cookie?

I found out that you cannot use a RewriteCond backreference as a pattern condition in the next Rewrite Cond... UPDATE: As it turns out, mod_rewrite doesn't expand any variables in the test pattern, ...
Eric's user avatar
  • 160
6 votes
2 answers
9k views

Regex negative look-ahead is not working for mod_rewrite between different Apache versions

I have a mod_rewrite line that works under Apache 2.2, but not under Apache 1.3: RewriteRule ^(?!index.php)(?!skin/)(?!js/)(.+) /index.php?file=$1 [NC,L] If I lose the negative ...
tjbp's user avatar
  • 193
1 vote
1 answer
47 views

Help with mod_rewite rule

I have a rule that will get the extension of every file from the url. I need to match all jpg, gif, png and bmp files. This is for a watermark application. Currently, it only matches jpg and Jpg. Can ...
user avatar
0 votes
4 answers
192 views

mod rewrite regex

The plan is to take domain.com/chat2/roomnumber and redirect to domain.com/chat2/index.php?room_id=roomnumber. Here's my code that's NOT workin: RewriteEngine on RewriteRule ^/chat2/([a-...
Benny B's user avatar
  • 159
0 votes
2 answers
140 views

Mod_Rewrite recipe

I need to accomplish the following with mod_rewrite: URI request: http://domain.com/user/username/ or http://domain.com/user/username URI translate: http://domain.com/?q=user/username This needs to ...
user avatar
0 votes
2 answers
347 views

ModRewrite 9 Back Reference Limit

This is a complicated one which I hope has a simple answer... RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) category.php?c_id=$2&filters=$3&_p=$4&name=$1 This rule would pick ...
icelizard's user avatar
  • 732
1 vote
2 answers
3k views

Apache mod_rewrite, using current URL in RewriteCond

I have several RewriteRules in an Apache VirtualHost configuration. I'd like to be able to test the current URL (after the preceeding rewrites) against some condition. The problem is that the ...
Daniel Beardsley's user avatar