url-rewriting

Add trailing slashes in WordPress Multisite without damaging the admin interface or the JSON API

六月ゝ 毕业季﹏ 提交于 2021-01-29 07:27:31
问题 For a WordPress multisite installation I am having the following part of my .htaccess: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^.]+)([^./])$ %{REQUEST_URI}/ [L,R=301,NE] In a single WordPress installation where /wp-admin and /wp-json always follow directly after the domain I can exclude those from the trailing slash rule with this: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/wp-admin

IIS URL Rewrite rule to replace part of the URL

你说的曾经没有我的故事 提交于 2021-01-29 05:15:06
问题 I am new to the IIS Rewrite rule and trying to create a rule to replace part of url e.g.www.abc.com/assets/global/xyz.jpg should redirect to www.abc.com**/en/globalassets/**assets/global/xyz.jpg I fiddle around with the following rule but no success <rule name="url replace"> <match url="^(.com/assets/global/)" /> <action type="Rewrite" url=".com/en/globalassets/assets/global/{R:2}" /> </rule> 回答1: According to your description, I have tested on my side , you could use urlrewite rule as below:

IIS: Rewrite URL with regex but keep query strings

ⅰ亾dé卋堺 提交于 2021-01-29 05:01:21
问题 I'm have the following link https://example.com/myapp/green?&lang=en&instance=some%20instance I need to rewrite it to the following link https://example.com/myapp?color=green&lang=en&instance=some%20instance The color in the link can be any color but it needs to be rewritten like in the 2nd link so that the trailing slash is replaced with a ? followed by the word color= and the ? at the end of the color word needs to be removed. /myapp/green? becomes /myapp?color=green , /myapp/blue? becomes

URL rewriting with .htaccess and relative paths

烂漫一生 提交于 2021-01-28 18:10:59
问题 I have a small problem with rewriting urls. I have this really simple rewrite rule: RewriteEngine on RewriteRule ^(home|apps|news|research|contribute)/$ index.php?page=$1 However, whenever I call my website like this, e.g. website.net/home/ it correctly rewrites the rule and shows the corresponding page but also messes up the css and images since it rewrites the urls for them since they are relative paths in the code. Is there any easy way to prevent this from happening? 回答1: This is because

Rewrite rule for the root file in nginx?

拈花ヽ惹草 提交于 2021-01-28 15:54:09
问题 I just want to redirect / to a different file rather than index.php/.html. So on apache I can do this.. RewriteCond %{REQUEST_FILENAME} -f RewriteRule . /path/to/dir/index.html [L] Trying this in nginx just doesn't even get run, it seems: if (-f $request_filename){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite /. /path/to/dir/index.html last; } Also tried this: if ($request_filename ~ "/index.php"){ set $rule_3 1$rule_3; } if ($args ~ "^$"){ set $rule_3 2$rule_3; } if ($rule_3 = "21"){

Rewrite rule for the root file in nginx?

偶尔善良 提交于 2021-01-28 15:40:21
问题 I just want to redirect / to a different file rather than index.php/.html. So on apache I can do this.. RewriteCond %{REQUEST_FILENAME} -f RewriteRule . /path/to/dir/index.html [L] Trying this in nginx just doesn't even get run, it seems: if (-f $request_filename){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ rewrite /. /path/to/dir/index.html last; } Also tried this: if ($request_filename ~ "/index.php"){ set $rule_3 1$rule_3; } if ($args ~ "^$"){ set $rule_3 2$rule_3; } if ($rule_3 = "21"){

Rewrite URL parameters as directories - like a Wikipedia URL

喜欢而已 提交于 2021-01-28 08:07:16
问题 I'm running a wiki and the URLs look like this: /wiki/index.php?title=MyTitle But I'd like it to look like this: /wiki/MyTitle How can I do this? I assume this can be done with .htaccess and rewrite rules, and I've looked around on this site and on google but I can't find anything that's really helping me. Right now I've got this, in the .htaccess for the /wiki/ directory. RewriteEngine on RewriteOptions MaxRedirects=1 RewriteRule ^(.+) index\.php\?title=$1 [L] But that just redirects me to

How to get message by id discord.py

房东的猫 提交于 2021-01-28 03:20:22
问题 I'm wondering how to get a message by its message id. I have tried discord.fetch_message(id) and discord.get_message(id) , but both raise: Command raised an exception: AttributeError: module 'discord' has no attribute 'fetch_message'/'get_message' 回答1: When getting a message, you're going to need an abc.Messageable object - essentially an object where you can send a message in, for example a text channel, a DM etc. Example: @bot.command() async def getmsg(ctx, msgID: int): # yes, you can do

Redirect with nginx (remove substring from url)

半世苍凉 提交于 2021-01-27 19:11:25
问题 I want do a redirect from old url: http://example.org/xxxxxxxxx.html To new urls (remove ".html") http://example.org/xxxxxxxxx How I can do this with nginx? EDIT : xxxxxxxxx can be differ, example: http://example.org/url-1.html redirect to http://example.org/url-1 http://example.org/another-url.html redirect to http://example.org/another-url 回答1: location ~ ^(.*)\.html$ { return 301 $1; } 回答2: Probably you need a rewrite statement location /xxx.html { rewrite ^/xxx(.*) http://example.org

How can I rewrite query parameters to path parameters in Apache?

爱⌒轻易说出口 提交于 2021-01-27 18:37:43
问题 I currently have a website that I am trying to optimize in terms of SEO. I've got the site working with URLs such as: domain.com/?app=about In my app, $_GET[app] is set to 'about', as expected. Now, I want to make it so that a URL like domain.com/about is treated as if it were domain.com/?app=about . How can I do this in an Apache .htaccess file? 回答1: These are known as RewriteRule s, and they are fairly straightforward: RewriteEngine on RewriteRule ^about$ /index.php?app=about Here's the