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
1
vote
1 answer

Apache mod_rewrite/mod_redirect: convert URL with query parameters into an SEO-friendly URL. some query parameters are ignored

As above. might be best explained with an example: original URL (the order of the params is NOT consistent) www.myhost.com/my-page?p1=v1&p2=v2&p3=v3 OR www.myhost.com/my-page?p2=v2&p1=v1&p3=v3 OR www.myhost.com/my-page?p3=v3&p1=v1&p2=v2 If I…
mrjayviper
  • 187
  • 1
  • 11
1
vote
1 answer

RewriteRule is applied to all files during directory listing

With Options Indexes and LogLevel rewrite:trace6 I see that my rewrite rule is applied to all files in the directory being listed. It even goes inside sub-directories and looks for index.html. This is bad for performance. Is this really necessary?…
basin
  • 558
  • 1
  • 5
  • 22
1
vote
1 answer

Website root trailing slash auto-removed (issue)

as per title, when I enter my website URL manually (examples at the end of the topic), the trailing slash at the end of the domain being removed automatically. I have SSL redirect forced and Apache ModRewrite enabled in .htaccess and this is the…
simone_meh
  • 15
  • 4
1
vote
1 answer

Apache 2.4 Convert .htaccess and rewrite it to vhost.conf

I am rewriting the Apache 2.4 configuration that I've received from the old development team. I have ~200 lines of similar configuration, and I can not understand on what principle I need to change this code to move it from .htaccess to…
1
vote
1 answer

Rewriterule not working with Joomla urls due to question mark and other special characters, also due to long urls

So I moved from Joomla CMS and now I need to finish my permanent redirects, but the following redirect isn't working (it's actually returning an error 404): RewriteCond %{HOST_NAME} =&?$ #RewriteRule…
1
vote
2 answers

How to prevent apache from restarting the rewrite processing within a "directory context"

I have the following in my virtualhost for SSL connections (my non ssl virtual host looks the same, but without the first rule set for redirecting). DocumentRoot /var/www/example.com/public/ #only…
chris
  • 136
  • 5
1
vote
1 answer

How to load requested file from sub-directory without rewriting base

Utilizing .htaccess rules, I'm attempting to load a file from within a sub-directory while keeping the frontend URL unchanged if both the domain and file path match criteria. Example of URL: example.com/specificfile.xml The file itself is within a…
sparecycle
  • 459
  • 1
  • 6
  • 19
1
vote
1 answer

RewriteRule with flag [L] stopping caching?

I use server management software plesk with apache and nginx. I set in apache and nginx a expired header for javascript files for one year. That's working. I can see one year for "expires" in header. Now I want access javascript and php files with a…
user706420
  • 113
  • 4
1
vote
1 answer

After installing script all subdomains go to the main domain

I have a main domain www.example.com. and the following subdomains under the main domain support.example.com test.example.com Previously both subdomains are working fine. But after installing a PHP script on the main domain, only the main domain is…
srisree
  • 11
  • 2
1
vote
1 answer

Redirect the document root and a specific page only to another domain

Might sound confusing, but what I want to achieve is this: If the user visits: www.mydomain.com (with or without www.) transfer them to: www.myotherdomain.com/welcome-old-users At the same time, I want to achieve this: If they…
1
vote
1 answer

Forwarding Apache SSL-Port to Web-App on localhost

I'm struggeling for days now to route a subdomain with SSL to a local running vue app, specifically the directus admin ui. I've done this before, like with the tool monit, and it worked like a charm: ServerName…
sagerobert
  • 119
  • 3
1
vote
1 answer

Apache rewrite causes server error 403 when genuine directory exists after extension removal rewrite

I've spent a couple of days now trying to create a specific rule set that will allow me to remove .html extensions from all the files in the directory and present neater URIs. I'm using a .htaccess file in the root directory of that website and the…
iratefox
  • 13
  • 3
1
vote
4 answers

Apache Rewrite: How to write a rule based on domain name (instead of HTTP_HOST)?

I have written a RewriteRule which works on the basis of HTTP_HOST (www.domainname.com), but I want it to work on the basis of the domain name part only (domainname.com). To clarify further The folder structure is /var/www/domainName.com. When I…
Deepak Mittal
  • 4,153
  • 3
  • 17
  • 7
1
vote
1 answer

Rewrite instead of redirect with Azure Web App/Linux

I'm trying to configure rewrite rules with .htaccess on an Azure Web App with Linux+Apache(+PHP), however I can only get redirects to work (but no rewrites). The source is structured as…
1
vote
1 answer

Space in value part of RewriteMap

This question is related to Apache RewriteMap with URLs containing space doesn't work, but in this case the issue is a space in the value part of the map, not the key part. Say I have this entry: /a-normal-url/ /a-less-normal url/ As a…
dorian
  • 427
  • 1
  • 8
  • 24