Questions tagged [mod-rewrite]

URL rewriting module for the Apache web server. It is commonly used for so-called "pretty" URLs, but also provides the power and flexibility to perform various request handling tasks beyond simple substitutions.

0
votes
0answers
9 views

RewriteBase is not supported in IIS

I am converting the rewrite rules from an htaccess file in IIS using the URL Rewriter Module but the following error occurs. This directive was not converted because it is not supported by IIS: ...
0
votes
0answers
14 views

Redirect specific URL in .htaccess

Need to redirect a specific URL to another URL. but the problem is when the nested URL is also redirected. Below is the code i use. Redirect 301 www.domain.com/us/ www.domain.com/ The above code is ...
0
votes
0answers
5 views

How could i define predefined query string URL in Rewrite rule

I have more than one predefined query string and i route to another server with same query string.how could i define in rewrite rule. https:one.server.com/appName/jsoncall?call=PasswordChangeCall and ...
0
votes
0answers
28 views

How to print regexp default variable $1 without variable conflict

Apache regexp is for the most part similar to Perl regexp. How would I convert this Perl version of a regexp, to Apache regexp. mod_rewrite or RedirectMatch RewriteRule ^(de/)*reviews(.*) https://www....
0
votes
0answers
41 views

Redirect Loop, Faraway so Close

Basically I need to let through requests to a specific path: https://domainfoo.com/my-app?param1=ABC&paramY=123 Anything else, let's say, https://domainfoo.com/aboutus I need it redirected to ...
-1
votes
0answers
13 views

Rewrite everything after path, but stay in directory

What I have: feed/repo/*site files* I want to stay in feed/repo/ and only let the application in feed/repo/ get the url after this path. Example: http://localhost/feed/repo/param1/param2/param3?...
0
votes
0answers
12 views

Wildcard RewriteRule for 301 redirects in htaccess

I'm working on setting up a 301 redirect in an .htaccess file and I can get it to sorta work, but I'm not sure why it's not picking up on anything after a specific URL in the rewrite rule. I ...
0
votes
1answer
14 views

How to redirect everything but an specific path on a htaccess file?

I'm trying to create an htaccess file so that everything gets redirected to the root of the site except for an specific path /api/date. I have this: <IfModule mod_rewrite.c> RewriteEngine On ...
1
vote
1answer
29 views

htaccess 301 redirects for some URLs of acquired company site

I want to move some content from a website of a company we just acquired (company b) to my company's website (company a) and redirect those links from b to a. Easy enough, but I want to get rid of ...
1
vote
1answer
30 views

Internal Server Error 500 on Code Igniter running on centos in Google Cloud

I'm running a CI based web application that runs fine on its old server but I'm migrating it to a centos 7/cwp instance on google cloud. After i set it up how i normally setup CI, im getting HTTP ...
2
votes
1answer
31 views

.htaccess RewriteRule to encode ®

I need to rewrite any ® in the url parameters to %C2%AE (UTF-8) by using the RewriteRule in the .htaccess file. I need this because Internet Explorer is not accepting this special character, other ...
1
vote
2answers
23 views

.htaccess redirects if the condition doe not match

I am modifying the .htaccess file of a legacy PHP web application. I am not familiar with apache .htaccess syntax. I found this tutorial, https://www.elated.com/mod-rewrite-tutorial-for-absolute-...
0
votes
0answers
16 views

.htaccess Remove PHP extension HTTPS issue

I'm using the following code in my .htaccess file to remove PHP extensions: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R=301,L] ...
0
votes
1answer
11 views

Transparent RewriteRule does not apply to folders

I have created a RewriteRule in a .htaccess file to transparently redirect all requests to a specific domain to a subfolder. # mydomain.ch -> mydomain.ch/domainfolder RewriteCond %{HTTP_HOST} ^...
0
votes
0answers
11 views

How to load information from user cookie in Apache2 reverse proxy and using mod_rewrite or other module

I'm trying to retrieve the username from my aws.cognito.token Cookie, which is also my authentication cookie, inside my Apache 2 reverse-proxy on ubuntu. I'm really unsure how to bring in and ...
1
vote
1answer
27 views

how to htaccess mod rewrite php to mp4?

I need to make htaccess changes for a project I'm working on. Although I don't know much about this subject, I would like to state that I have made a few experiments. thats a original link: ...
0
votes
1answer
12 views

Apache url encode variable embeded in url parameter

I thought that the B flag would cause variables to be url encoded, but it doesn't work. The below injects %{QUERY_STRING} without encoding & into %26. RewriteRule ^(.*PATTERN.*) http://...
1
vote
1answer
22 views

Simulate directory with htaccess

When my main website opens, it retrieves content from /home/parsa/public_html. I have tried this: rewriteRule "^/(.*)$" "/ppyazi.com/$1" I need it to retrieve the files from /home/parsa/public_html/...
-1
votes
0answers
17 views

How to fix: Cant write '-' in URL

I can't write - in the URL. I think its because the htaccess-file. Here is my htaccess-file: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([\w]+)/?([\w]+)/?([\w]+)? index.php?...
0
votes
0answers
19 views

Apache2 Alias or mod_rewrite and PHP interaction / alternatives

I am working on a project which includes the ability for a user to have a custom webspace. In this project, each user has their own subdomain. At a minimum, I would like them to be able to switch the ...
0
votes
1answer
20 views

Rewrite Condition with Special Case for Homepage

I switch my Business from one Domainname to another and want to use a 301 Redirect/Rewrite to keep the Google Ranking. The special case is, that the Startpage and One other Page should go to a new ...
-2
votes
0answers
10 views

How to clean up url in php

I need to remove .php and ?id= from this url using .htaccess file. URL now - http://www.XXXX.com/blog.php?id=X What I need - http://www.XXXX.com/blog
0
votes
1answer
11 views

How do I configure Apache (.htaccess?) to use mod_rewrite to pass virtual path to PHP file?

I have a script located at http://www.foo.bar/script and would like to use virtual path names to send data to that script. For example, http://www.foo.bar/script/this/is/a/path would pass "this/is/a/...
0
votes
0answers
13 views

Modify output from REQUEST_URI

I have RewriteRule which is searching in RewriteMap and getting output from map and added query string with REQUEST_URI. It is working fine but now I would like modify REQUEST_URI output. ie. ...
0
votes
1answer
18 views

add file type extension using .htaccess in subdirectory?

I want to map links like https://website.com/test/STRING to https://website.com/test/STRING.png, how to do it with .htaccess? Options All -Indexes -MultiViews RewriteEngine on RewriteBase /test/ ...
2
votes
2answers
38 views

How to apply mod_rewrite rules to files within directory?

I'm trying to apply rewrite conditions in my htaccess file to all pages contained within a specific directory on my website, but not the directory index itself. Ultimately, I'm trying to remove .php ...
0
votes
0answers
9 views

Mod Rewrite issue under Apache 2.4

I had a mod rewrite code that worked fine under Apache 2.2. Now it is not working anymore. The below code was simply redirecting www.mysite.com/MyDirectory/param1/value1/param2/value2/ and everything ...
0
votes
0answers
9 views

Htaccess mod rewrite pretty links with language subfolder

I need help with setting up htaccess on my website: STEP 1: Redirect non-www to www http://example.com to http://www.example.com STEP 2: Force https http://www.example.com to https://www.example.com ...
0
votes
0answers
26 views

execute .htaccess rules without index file in folder

Site structure: site/client site/client/index.php site/client/.htaccess site/server site/server/main.php site/.htaccess site/.htaccess directives: Options -Indexes DirectoryIndex disabled ...
0
votes
0answers
7 views

unable to load php from interface folder

I am new to Apache and recently my developer passed me the website with htaccess to host on Apache 2.4 running on CentOS 7, the website is running on the Windows laptop but not on the server with the ...
0
votes
0answers
15 views

htaccess is not reading the internal directories

I have a project and directory structure is |project-root |--.htacess |--directory_1 |----.htaccess |--directory_2 |----.htaccess .htaccess on root cotains the following content <IfModule ...
0
votes
0answers
16 views

Rewrite rules to convert an url to a friendly one

I am getting the url in the form of http://<domain>/recepten.html?consolidatedFilter=voorgerechten_voorgerechten-vegetarisch/voorgerechten_voorgerechten-vis.html But I need to get http://&...
0
votes
0answers
5 views

Apache redirect fro subdomain.mysite.com to http://localhost:[port]

I have an application running in my server, localhost:4873. I want to redirect subdomain.mysite.com to http://localhost:4873 via .htaccess with redirect. I tried this, but I get an Internal Server ...
0
votes
0answers
16 views

modify URL PATH, cut something of, do not redirect [duplicate]

I want to cut off the first part of a URL such as /thisMustRM/here/we/go/to.php using RewriteRule. Below is what I've attempted by far; RewriteCond %{REQUEST_URI} !(.*)thisMustRM RewriteRule ^(.*)$ /...
0
votes
0answers
20 views

htaccess rewrite rule not working when file exists at rule location

I have the following code in my htaccess: #BEGIN screenshotaccess RewriteEngine On RewriteRule ^custom-media-files/$ https://google.com [L] RewriteRule ^custom-media-files/([0-9]+)/$ https://google....
0
votes
0answers
11 views

htaccess rewrite based on domains, redirect some to https, the others not

I have a lot of different domains (let's say www.site1.com, www.site2.com, www.site3.com and www.site4.com) that point to the same server. If a domain is entered without www I'll add it with my rules:...
0
votes
1answer
7 views

Rewrite Rule which takes wildcard characters and add it to the destination page

I need a rewrite rule which redirects to a subdomain, but takes takes everything from wildcard to the destination page for example: if https://example.org/product/abcde is called, the redirect ...
0
votes
1answer
28 views

Regex: “Mod Rewrite” everything from a “wildcard” to an address, without changing the address?

I really didn't know how to write the title. I changed it several times before I posted. But feel free to change it to the most appropriate question. I also can't believe I couldn't find an answer ...
0
votes
1answer
20 views

How to correct redirect url with parameter and change language

I have a problem with correct redirect using htacces file. My website have 3 language PL, EN and RU. Main language is PL and it works with ex. https://mypage.domain.pl/, if I add parameter language ...
0
votes
0answers
7 views

Apache Rewriting URL inorder to append extra path in URL

Let me tell us about the context : On server I installed gitlab and apache; I have configured everything to work if I connect to http://mydomain.foo it will display my gitlab application. I used the ...
0
votes
0answers
8 views

Redirect to another path

I would like to redirect https://test.cz/1.2/Site.htm#16 to https://test.cz/01.02/Site.htm#16 It is possible in Apache? I have access only to .htaccess file
0
votes
1answer
18 views

Rewrite rule combining both query string and passthrough is not working

I am trying to redirect a page A with query string, pageA?queryString to pageB. But while redirecting, pageB should be internally redirected. It should pass through and in URL it should show pageA but ...
0
votes
1answer
17 views

PHP RewriteRule combined with caching

My problem is that my .htaccess file on a location like: test.example.com/ doesn't redirect. My suspicion is that it is because of the cache rule in the same file. I think that they might interfere, ...
0
votes
1answer
14 views

Rewrite Rule For Existing File

I have robots.txt and script.php files on my server. I want to transfer all requests to robots.txt to script.php with the following code: RewriteEngine On RewriteCond %{REQUEST_URI} ^robots.txt$ ...
0
votes
0answers
14 views

Serve two internal servers using same apache2 server

I have a single AWS server where I want to host both Rstudio community server and jupyterhub. They by default run on port 8787 and 8000 respectively. I want to create an apache server that will do the ...
0
votes
0answers
8 views

HTACCESS 302 Redirect - CSS Source Map is breaking

I've got the following in my .htaccess file, so anyone accessing barberguard.co.uk should be redirected to /scheme/barberguard/ - when I take the below out the .htaccess file the fonts are rending ...
1
vote
2answers
47 views

.htaccess/mod_rewrite: running Angular app in sub-folder?

I've a light index.php which provides simple pages and a more complex/heavy Angular 8.0 app, stored in the sub-folder /app. Example URLs: / ......................... works: index.php, loads home ...
0
votes
1answer
27 views

.htaccess redirect to https with conditions page

I have the following .htaccess RewriteEngine On RewriteCond %{HTTPS} !on RewriteCond %{REQUEST_URI} !(/webservice|/api) RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{...
0
votes
1answer
12 views

How do I redirect specific file extensions from one directory (that no longer exists) to another?

We have just moved to a new site structure and some of our old directories no longer exist. Our old directory /html/ held both .jpg and .pdf files. Those files have now been moved into their own ...
1
vote
2answers
130 views

REQUEST_URI not matching explicit path and filename

Really stumped, because form and syntax seem fine. RewriteCond for REQUEST_URI is not matching the explicit path and filename. When isolated, RewriteCond for REQUEST_FILENAME matches just fine. I ...