mod-rewrite

Apache Configure CORS Headers for Whitelist Routes

允我心安 提交于 2021-02-08 10:14:27
问题 I'm trying to allow calls made to "/api/whateverEndpoint", while keeping CORS strict for all other calls. I've come across this link Whitelisted CORS using Apache which gives the solution for origin filtering: # e.g. origin = https://host-b.local SetEnvIfNoCase Origin "https://host-b.local" AccessControlAllowOrigin=$0 Header set Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin But i need to adapt this to filter based on the request uri. Any idea is greatly

nginx conditional rewrite issue

放肆的年华 提交于 2021-02-08 07:51:11
问题 location / { try_files $uri $uri/ /index.php?$args =404; rewrite ^/(\w+)$ /?system=$1 break; } This block rewrites /first to /?system=first , /second to /?system=second , etc. However, this rewrite should not be done for /six and /nine . How could I write this condition? 回答1: Fixed with regex rewrite ^/((?!six|nine)\b\w+$) /?system=$1 break; 来源: https://stackoverflow.com/questions/45526436/nginx-conditional-rewrite-issue

nginx conditional rewrite issue

无人久伴 提交于 2021-02-08 07:51:03
问题 location / { try_files $uri $uri/ /index.php?$args =404; rewrite ^/(\w+)$ /?system=$1 break; } This block rewrites /first to /?system=first , /second to /?system=second , etc. However, this rewrite should not be done for /six and /nine . How could I write this condition? 回答1: Fixed with regex rewrite ^/((?!six|nine)\b\w+$) /?system=$1 break; 来源: https://stackoverflow.com/questions/45526436/nginx-conditional-rewrite-issue

nginx conditional rewrite issue

不羁的心 提交于 2021-02-08 07:50:08
问题 location / { try_files $uri $uri/ /index.php?$args =404; rewrite ^/(\w+)$ /?system=$1 break; } This block rewrites /first to /?system=first , /second to /?system=second , etc. However, this rewrite should not be done for /six and /nine . How could I write this condition? 回答1: Fixed with regex rewrite ^/((?!six|nine)\b\w+$) /?system=$1 break; 来源: https://stackoverflow.com/questions/45526436/nginx-conditional-rewrite-issue

RewriteRule without FollowSymLinks or SymLinksIfOwnersMatch

我只是一个虾纸丫 提交于 2021-02-08 06:37:56
问题 I'm running into some problems with rewriting my URLs. Recently moved to a new host where FollowSymLinks and SymLinksIfOwnersMatch is not allowed as options in my .htaccess file. Using these will give me a 500 error. Mod_rewrite is however enabled on the host. Normally my rewriting code looks like the code below and works perfectly: Options +FollowSymLinks RewriteEngine on RewriteRule ^link/(.*)$ link.php?urlkey=$1 [QSA] But with removing +FollowSymLinks the rewriting doesn't work. Any idea

RewriteRule without FollowSymLinks or SymLinksIfOwnersMatch

落花浮王杯 提交于 2021-02-08 06:37:37
问题 I'm running into some problems with rewriting my URLs. Recently moved to a new host where FollowSymLinks and SymLinksIfOwnersMatch is not allowed as options in my .htaccess file. Using these will give me a 500 error. Mod_rewrite is however enabled on the host. Normally my rewriting code looks like the code below and works perfectly: Options +FollowSymLinks RewriteEngine on RewriteRule ^link/(.*)$ link.php?urlkey=$1 [QSA] But with removing +FollowSymLinks the rewriting doesn't work. Any idea

htaccess: Remove and disable file ending

为君一笑 提交于 2021-02-08 05:11:46
问题 I'd plastered all over the Internet that this code in your .htaccess file will remove the file ending: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php However, although enables the URL without file ending, it does not disable the URL with file ending. Essentially, what I'd like to force any attempt for an request with file ending (domain.com/sample.php) to end up without file ending (domain.com/sample) I'm sure someone

AngularJS SSL .htaccess woes

佐手、 提交于 2021-02-08 02:12:24
问题 I'm trying to enable the use of SSL on my .htaccess file that has already been set up for html5Mode direct linking but it's always resulting in a redirect loop. The closest question I've found on stackoverflow is this but even from here I can't figure it out (I'm new to htaccess files). AngularJS html5Mode direct linking htaccess file is RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] and this works

AngularJS SSL .htaccess woes

一个人想着一个人 提交于 2021-02-08 02:05:21
问题 I'm trying to enable the use of SSL on my .htaccess file that has already been set up for html5Mode direct linking but it's always resulting in a redirect loop. The closest question I've found on stackoverflow is this but even from here I can't figure it out (I'm new to htaccess files). AngularJS html5Mode direct linking htaccess file is RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] and this works

.htaccess doesn't escape question mark on RewriteRule

佐手、 提交于 2021-02-07 20:55:14
问题 I have a website with an old type of Single Sign On. A parent website sends users to my website with a URL like: http://test.instela.fm/index.php?gid=abcd1234&u=thedewil&id=11472 and I want to rewrite it as this: http://test.instela.fm/login/abcd1234/thedewil/11472 I have created a .htaccess file as following: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^index.php?gid=(.*)&u=(.*)&id=(.*)$ login/$1/$2/$3 [L] I tried escaping the question mark in the URL