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
3 answers

Getting mod_rewrite working on OS X Snow Leopard

I have a OS X 10.6 install working, with Apache and PHP installed. However, I cannot get mod_rewrite working. The contents of my httpd.conf is located here: http://pastie.org/828990 Does anyone know what vital thing I'm missing?
Neil Middleton
  • 412
  • 1
  • 4
  • 11
1
vote
2 answers

Is this an unsafe Apache Rewrite Rule?

I've got a rewrite rule set up like this: RewriteCond %{DOCUMENT_ROOT}/cache/%{REQUEST_URI} -f RewriteRule ^(.*)$ cache/$1 [QSA,PT,L] Brief explanation for this rule: it checks to see if a requested file exists in the cache directory. If it does,…
Eliot Sykes
  • 153
  • 4
1
vote
0 answers

Apache Rewrite Based on Query String

I'm trying to detect the presence of a particular name/value pair in the query string and, if it exists, do a thing. I'm trying to do this in a conf file that's stored in conf-available/ and after a2enconf has been run to enable it. The code is…
Rob Wilkerson
  • 1,465
  • 4
  • 17
  • 25
1
vote
1 answer

rewrite based on script in URL

Using Apache 2.2.x -- my usual approach to blocking script kiddies from looking for various scripts on the server is to use dynamically created 'deny from' lists with the offending ip's. Works, but is always at least a step behind. So, thinking…
Johnny Canuck
  • 141
  • 1
  • 2
1
vote
1 answer

Apache 2.4 expr - how to load a html file via RewriteRule?

On Apache 2.4, Having a bunch of mixed SEO friendly and dynamic URLs on an ecom site I want to implement a simple caching system for my blog posts and product pages. First I want to have md5(REQUEST_URI+QUERY_STRING) and then load the prerendered…
nikis
  • 11
  • 1
1
vote
1 answer

How to replace custom url old domain to new domain with .htaccess

How to replace all url entire website with new domain and new permalink? I have 5k url to replace at my site. Example : Current URL: oldomain.com/2020/12/data-raid-4963.html Replace To: sub.newdomain.com/4963-2/ Current URL:…
1
vote
1 answer

mod_rewrite rules on subdirectory not woring due to parent rules

My application lives in one directory and is served from a public folder, and I have an API endpoint in a sub-directory of public, both of which are redirected to their own respective index.php files. Until a recent server migration everything was…
oucil
  • 557
  • 6
  • 21
1
vote
0 answers

Apache 2.4 "client denied by server configuration" caused by Require expr - even though the request succeeds

Our apache error log is littered with messages saying client denied by server configuration, even though the htaccess configuration is working as intended. Here is the relevant bit of the htaccess: SetEnvIfExpr "req_novary('User-Agent') =~…
Jonathan
  • 111
  • 3
1
vote
1 answer

Apache ToLower on all Wordpress pages (not PDF/CSS/JS)

I'm having issues performing a 301 redirection of URLs that contain capitals to lowercase, excluding static files (PDF/CSS/JS/JPEG/JPG/PNG/WEBP...etc). For example: https://www.example.com/Page/ would become https://www.example.com/page/ but…
1
vote
1 answer

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 other words the . needs removing. I figured a…
1
vote
1 answer

Apache htaccess ruleset: Try request as: 1) file as-is 2) file + .html suffix 3) DirectoryIndex 4) Else to index.php CMS router

I'd like to express this ruleset If the request is /hello then try the following in the given order: /hello — File of that name exists (file without file extension). Edit: Not a necessity. Only a possibility/compromise. Drop if too…
porg
  • 143
  • 5
1
vote
1 answer

htaccess: 301 redirect defined URLs to new domain and catch all redirect the rest

I want to redirect some URLs from an old domain to new versions on a new domain. The old domain uses the www. subdomain and SSL. For example: olddomain.com/audi -> newdomain.com/cars/audi olddomain.com/bmw -> newdomain.com/cars/bmw But there are…
Cray
  • 135
  • 5
1
vote
2 answers

How to install mod_rewrite on Ubuntu for Drupal 6

would anyone have some easy to follow step on how to install mod_rewrite on Ubuntu, its for Drupal 6
freddy6
  • 115
  • 2
  • 3
  • 10
1
vote
1 answer

How Can We Do 301 Redirect Of Over 200 Pages To Corresponding 200 Pages At New Location?

I need help and need it fast. We recently migrated a subdomain to integrate with the domain. Eg. https://blog.example.com to https://www.example.com/blog https://blog.example.com has a ton of traffic which we don't want to lose. So we need to do 301…
1
vote
1 answer

Apache mod_rewrite RewriteRule loops despite L flag

Apache/2.4.54. I am trying to achieve that similar URLs (e.g. "/anystuff.htm") are externally redirected to "/something" which internally is "something.html". But the following rules cause a loop instead of stopping, i.e. "something" is…
handle
  • 113
  • 3