Questions tagged [mod-rewrite]

mod_rewrite is an Apache module that allows for server-side manipulation of requested URLs.

For an introduction and examples of using mod_rewrite, read over the comprehensive article,
"Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask"

2224 questions
0
votes
1 answer

Apache2 RewriteRule does not work

I configured my apache2 like this before: ... RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule "^/?(.*)" "https://%{SERVER_NAME}/$1" # HTTPS auto redirect RewriteRule "^/example/?$"…
whc2001
  • 25
  • 1
  • 5
0
votes
0 answers

Why does mod_rewrite require FollowSymLinks or SymLinksIfOwnerMatch?

I would like to disable FollowSymLinks and SymLinksIfOwnerMatch options, but at the same time I do want to use mod_rewrite. I checked the source code of apache 2.4 and I found there is only a condition that does not allow RewriteEngine On, when the…
0
votes
2 answers

Redirect subdomain to hidden folder using mod_rewrite

I want to keep my blog in subfolder domain_com/htdocs/blog and access it using blog.domain.com. I can obtain it using apache's mod_rewrite: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^blog\.domain\.com RewriteCond %{HTTP_HOST}…
radious
  • 1,022
  • 6
  • 5
0
votes
1 answer

Redirection, subtitute or rewrite

we have a homepage hosted by another provider in amazon, we are developing and event related page, due a SEO needs we need a redirection from http://www.example.com/event (hosted on amazon, out of our control) to http://event.example.com (hosted on…
0
votes
1 answer

Mod_Rewrite Modify Query String Help

I need some assitance with a mod_rewrite rule. I am setting up a SEO Friendly director of names and have run into some problems I know there is an easy answer for but I cant get it to work to save my life. Here is a sample URL's that we would like…
0
votes
0 answers

PT rule in .htaccess in subdirectory that will be processed in .htaccess for parent directory

I have a PHP project that exposes its API under /api/public/(xyz). The http root directory has .htaccess file that rewrites those requests to be processed by index.php. For reason not relevant here, we want to expoze (xyz) methods under…
0
votes
0 answers

Rewrite URL after Symfony rewrites rules

The goal is to add the locale "en" at the beginning of the URLs which doesn't have it. Example https://example.com/document/file.php Becomes https://example.com/en/document/file.php The following rule works fine alone: RewriteCond %{REQUEST_URI}…
0
votes
1 answer

How to use htaccess to restrict access to script when rewriting?

I have a php script that relies on the following rewrite rules: RewriteEngine on RewriteCond %{REQUEST_URI} !^/script.*$ [NC] RewriteRule (.*)$ script.php/go [QSA,L] So when someone visits http://example.com/foo, the script is called…
0
votes
2 answers

Apache rewrite URL if accessed in specific directory

We have two servers, and some content was moved to our old server, but, there are still some links on the web to those old directories on our old server. So, any page in www.mysite.com/Pages/page.html I need to rewrite/redirect to…
Zed Said
  • 717
  • 6
  • 14
  • 25
0
votes
1 answer

Website stopped working - bad flag delimiters error

I've had a website that has worked for a year. I changed the domain name, and the hosting company copied all of the data to the new hosting account. The website worked for a few days. Now, with no changes made, I've got a 500 Internal Server…
RobD
  • 1
0
votes
0 answers

Apache URL redirect using RewriteMap

I am struggling with the last part, writing proper RewriteRule (maybe I also need RewriteCond?). I have this mapping.txt: apple 30/products/apple.png xerox 38/products/xerox-300.png dell 3021/products/dell_img.png ... with it I want to do URL…
c0dehunter
  • 293
  • 1
  • 4
  • 11
0
votes
1 answer

How to add the trailing slash in general for an Apache + CDN architecture (without using Apache mod_rewrite)?

I would like to add the trailing slash in general when it is absent in the request URL: when user requests https://example.com/blog, it should be redirected to https://example.com/blog/ when user requests https://example.com/abc.jpg, it should be…
0
votes
1 answer

switch mod rewritten URL

We are using a mod rewritten URL within our PHP site, this is the rewrite rule we are using: RewriteRule ^category/([^.]+)/([0-9]+)/([^.]+)/([0-9]+) categories.php?c_id=$2&filters=$3&_p=$4&area=category&areaname=$1 However, a user of a different…
robjmills
  • 990
  • 9
  • 26
0
votes
1 answer

RewriteEngine rules ignored by Apache on SSL

I have a working Apache setup on CentOS 7.6 using the standard Apache 2.4.6-88 package, using HTTP. I am trying to enable HTTPS on the server, and everything works, except for my RewriteEngine rules. I cannot find any mention anywhere about…
nafmo
  • 450
  • 4
  • 13
0
votes
1 answer

Apache destination virtual host certificate when using mod_rewrite or ProxyPass

I am trying to use mod_rewrite or ProxyPass to redirect (PT) the client's request from virtual host A on 443 to different virtual host B on port 4434, also with SSL. Like that: SSLProxyEngine on SSLProxyVerify none SSLProxyCheckPeerCN…