URL Rewriting maps an incoming URL to a modified URL, so that the request is processes as if the original request was made to the modified URL. This is often used to provide more search engine friendly URLs.
Questions tagged [rewrite]
2112 questions
4
votes
0 answers
nginx equivalent to Apache MultiViews?
If you put this in your .htaccess file
Options MultiViews
and you have these files
stuff/
howto.html
index.php
items.php
then all of these web addresses work
/stuff/ # brings up /stuff/index.php.
# Yes, this…

Andrew Banks
- 41
- 3
4
votes
2 answers
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 that would correspond to the $1 backreference. It…

Ezekiel Victor
- 171
- 7
4
votes
1 answer
IIS7 and URLRewrite is failing with Wordpress 3.1.1 Redirects
I'm having an interesting issue with the migration to wordpress 3.1.1 multisite and the url rewrite rules. the index.php routing, as well as the ms-files.php?file= rules are failing across the board. The ROOT site has functionality thats working,…

lazyPower
- 143
- 6
4
votes
1 answer
Is it possible to change url rewrites on IIS7 without restarting the app?
We're currently using ISAPI rewrite. However, we're moving to servers with IIS7 on them. If we're going down the route of using IIS7's url rewriting tool (which, if I remember correctly changes the web.config, which in turn causes an application…

Piers Karsenbarg
- 548
- 3
- 12
- 24
4
votes
1 answer
Rewrite a subdirectory to root on nginx
let's say I have a site http://domain/ and I put some files in a subdirectory /html_root/app/ and I use the following rewrite rule to rewrite this folder to my root:
location / {
root /html_root;
index index.php index.html index.htm;
#…

sparanoid
- 205
- 3
- 7
4
votes
1 answer
How to redirect elgantly many redirects in htaccess?
Q1. is it possible to further optimize / compact the following rules, thereby making the entire redirections faster and easier to maintain in future? There are about twenty of these domains!! you get the picture of my problem! Thanks very much for…

Sam
- 423
- 3
- 7
- 23
4
votes
2 answers
Apache-style multiviews with Nginx
I'm interested in switching from Apache/mod_php to Nginx for some non-CMS sites I'm running. The sites in question are either completely static HTML files or simple PHP, but the one thing they have in common is that I'm currently using Apache's…

Kenn
- 145
- 2
- 7
4
votes
2 answers
Can I make a simple calculation within a RewriteRule?
A change in how a site is structured means urls need changing from
site/11-foo/21-bar
to
site/1-foo/1-bar
i.e. I want to use a RewriteRule to subtract a constant (in this example, 10) from the integer in the 2nd argument and another constant…

lazysoundsystem
- 195
- 1
- 6
4
votes
1 answer
use "rewrite" and "try_files" together [Nginx]
I removed the ".php" suffix at the end of the PHP files on the Nginx server with the following code, but this time I cannot send some data to the server.
try_files $uri/ $uri.html $uri.php$is_args$query_string;
Some links on the site are sent with…

Emre6
- 151
- 2
4
votes
1 answer
htaccess rewrite /dir/*.jpg to /dir/webp/*.webp only when webp file exists
I'm trying to rewrite all website files (*.jpg|*.gif|*.png) to *.webp in a subdir, but only when the *.webp file exists. Previous and new files have the same name, only changing the extension and *.webp files are all under subdir of the original…

Diego Flores
- 73
- 4
3
votes
1 answer
Using Apache rewrite rules in .htaccess to remove .html causing a 500 error
I have written a small website (4 pages, HTML only) and I want to remove the .html extension from the URL by putting some rewrite rules in my .htaccess file, I've Googled around and found several snippets similar to this:
…

Enicli
- 43
- 1
- 7
3
votes
1 answer
Nginx reverse proxy hide url
Here is my nginx proxy.conf file,
server {
listen port 9090;
root /usr/share/nginx/html; # not sure whether this line is needed or not
index index.html; # not sure whether this line is needed or not
location / {
proxy_pass…

Mr Emp
- 41
- 2
- 5
3
votes
1 answer
Nginx rewrite issue with question mark
I am using nginx 1.14.0 on Ubuntu.
I want anyone coming to https://www.example.com/blog/authors/ should always redirected to https://www.example.com/blog which is working fine, but if anyone comes through https://www.example.com/blog/authors/?hello…

Farmi
- 379
- 1
- 4
- 17
3
votes
0 answers
Need to rewrite domain with specific criteria on Nginx
I have a server with multiple domains pointing to it (it has Wordpress Multisite running on it).
One of those domains (e.g., mydomain.xxx) I need to redirect to another domain, which is on a different server, yet I want to let through request to…

inspirednz
- 173
- 1
- 9
3
votes
1 answer
RewriteCond: check is %{HTTP_REFERER} include or equals %{REQUEST_URI}
Is there a way to check using RewriteCond whether the Referer includes the requested URI or...
RewriteCond %{HTTP_REFERER} == 'host.com/' + %{REQUEST_URI} ...
?
I need to catch whether the surfer clicked a link on the page which links to the same…

slava
- 161
- 2
- 11