New answers tagged

0

Setting ServerAlias directive in site config should work. <VirtualHost *:80> ServerName foo.bar.int ServerAlias www.foo.int DocumentRoot /opt/foo <Directory /opt/foo> Order deny,allow Allow from all Require all granted </Directory> </VirtualHost>


0

This solved my issue. Sad to say that there is not many articles related to these issue, even nginx doesn't provide user friendly Help/Tutorials. location ~* ^/-PageOne.html { rewrite ^ /seo.php?page_id=1 last; } Hope this helps!


1

Proposed solution (showing only the location blocks): location ~ ./$ { rewrite ^(.*)/ $1 last; } location / { if ($request_uri ~ ^(.*)\.(php|htm)) { return 302 $1$is_args$args; } try_files $uri $uri/index.html $uri/index.htm @php; } location @php { try_files $uri.php $uri/index.php =404; include /etc/nginx/fastcgi_params; ...


1

The following line adds a ? to the end of any externally presented URI ending with .php: if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }`. A quick fix would be to use $is_args instead of the ?. See this document for details.


0

For me it worked without the equals sign like this: location /old-url { return 301 /new-url; }


0

Try something like this - I can't guarantee it will work, but it's worth a shot. Basically it's saying "send requests for the UI folder to this other server". You may need the rewrite in the other answer as well or instead. location /ui { proxy_pass (etc); }


0

I put this inside my https server block and it redirects the given url, in this example https://subdomain.domain.com to https://subdomain.domain.com/ui and send a permanent flag to remote browser for future reference/speed. I assume that is why atleast rewrite ^/$ /ui permanent; or rewrite ^/$ /path permanent; Full Configs: server { listen ...


3

You can use a rewrite. For example rewrite all PHP scripts with trailing /: location / { rewrite ^/(.+\.php)(/.+) /$1?$2; try_files $uri $uri/ =404; }


0

To change the URL displayed in the client's browser's address field, you need an external redirect: rewrite ^(.*)[-_](.*)$ $1$2 permanent; If you need to restrict the scope of the rewrite, for example, so that /http-bind/ is not rewritten, you can make the regex more specific: rewrite ^(/[^/]*)[-_]([^/]*)$ $1$2 permanent; Explanation: capture and match ...


1

Maybe this syntax variation will help you? try_files $uri $uri/ /index.php$uri?$args; This tries folders as well as files before passing it on to the backend if they don't physically exist.


0

In this case, an HTTP Redirect instruction configured in IIS was interfering. EDIT: At the web site node in IIS Manager, I had an HTTP Redirect configured. The "Redirect requests to this destination" checkbox was checked, with "https://www.thisismysite.com" (minus "this is". Thanks formatting...) as the address. Below, under "Redirect behavior", "Redirect ...


0

So, after more research and trial and error I was able to figure it out. Here is how I have it setup now. <rule name="Redirect1" stopProcessing="true"> <match url="^(.*)$" /> <conditions> <add input="{R:0}" pattern="^(?!\s*$).+$"/> <add input="{R:0}" pattern="^[a-zA-Z0-9_]*$" ...


1

try this server { listen 80; listen [::]:80; root /home/www/example.com/htdocs; index index.php; server_name www.example.com; location ~* ^[^\?\&]+\.(html|jpg|jpeg|json|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|svg|woff|ttf)$ { # First attempt to serve request as file, then # as directory, then fall ...


1

location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php; } }


1

ServerName accepts a scheme as well, e.g. ServerName https://example.com. Changing this in the configuration and restarting Apache did the trick. From the documentation: Sometimes, the server runs behind a device that processes SSL, such as a reverse proxy, load balancer or SSL offload appliance. When this is the case, specify the https:// scheme and ...


0

Try this: acl get_foo_com hdr(host) -i get.foo.com http-request redirect location http://foodownload.com/bar.mp4 code 301 if get_foo_com What this does: Checks the provided host against get.foo.com; evaluates to TRUE or FALSE. Redirects the client via 301 Moved permanently to http://foodownload.com/bar.mp4 if get_foo_com is TRUE. For more information ...


0

Below method solved my problem. Now i am able to browse: mywebsite.com - .aspx mywebsite.com - .html mywebsite.com/blog - .php File http.conf: RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} blog RewriteRule . /blog/index.php [L]


1

This will replace the plus with a hyphen for you: location ^~ /city/ { # For the single word case, just copy the city name set $city $arg_sl_city; # If the city is two words, convert + to "-" if ($arg_sl_city ~* "(\w+)[-+](\w+)") { set $city "$1-$2"; } set $args ''; rewrite ^.*$ /locations/$city permanent; } However, ...



Top 50 recent answers are included