url-rewriting

Directing Non-Slash URL to Slash

北战南征 提交于 2021-02-10 11:03:29
问题 When I enter the website.com/seo link, I want to make a 301 redirect to the website.com/seo/ link. However, I don't want it to be broken in the codes I wrote in the current htaccess. my htacces codes: RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ $1.php [NC,L] 回答1: Use only one of these, do not use together! Try: RewriteEngine

NGINX 301 redirect using query argument value

自古美人都是妖i 提交于 2021-02-08 11:17:29
问题 I want to redirect example.com/?lang=en to example.com/en/ . I am using Python Django and my server running Plesk / Nginx. I try to redirect on my webpage like this. But it's don't work; rewrite ^/?lang=en$ /en/ redirect; But if i remove question mark rewrite is worked. I tried many methods but I couldn't find a solution. Thank You. 回答1: The most simple is if ($arg_lang = en) { return 301 /en$uri; } However if you'd have any other query arguments, they would lost with this redirection rule.

NGINX 301 redirect using query argument value

ぃ、小莉子 提交于 2021-02-08 11:15:25
问题 I want to redirect example.com/?lang=en to example.com/en/ . I am using Python Django and my server running Plesk / Nginx. I try to redirect on my webpage like this. But it's don't work; rewrite ^/?lang=en$ /en/ redirect; But if i remove question mark rewrite is worked. I tried many methods but I couldn't find a solution. Thank You. 回答1: The most simple is if ($arg_lang = en) { return 301 /en$uri; } However if you'd have any other query arguments, they would lost with this redirection rule.

IIS does not encode utf-8 urls?

一世执手 提交于 2021-02-08 08:50:08
问题 I'm running Joomla 2.5 on an IIS7 server. The problem is Joomla's search engine friendly urls don't work. Whatever url I enter, it goes to index.php. After a painful day of struggling with rewrite rules and IIS settings, I came to two realizations: Search engine friendly urls are only broken when the urls are unicode. In my WAMP server, on which the SEF urls work perfectly: $_SERVER['REQUEST_URI'] is "mydomain/%D9%85%D8%AD%D8%B5%D9%88%D9%84%D8%A7%D8%AA/%D9%82%D9%84%D8%A8%DB%8C-%D8%B9%D8%B1%D9

Redirect 301 Nginx with query string “?amp” - AMP Nginx Redirect

若如初见. 提交于 2021-02-08 06:54:18
问题 I'm trying to make a rewrite rule in Nginx, that contains "?amp" at the end of the request, like this: From http://mywebsite.com/path1/lalala?amp To http://mywebsite.com/path1/lalala It's a redirect 301. I tried some rules, but they do not work, I get many redirects (looping). Examples that did not work. rewrite ^/path1/lalala.*? htttp://mywebsite.com/path1/lalala? permanent; Or rewrite ^/path1/lalala.*? /path1/lalala? permanent; I think the problem is in the query string "?amp". Do you know

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

URL Rewriting - Redirect With No File Extension

情到浓时终转凉″ 提交于 2021-02-07 19:45:57
问题 I am currently using the following rules in a .htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php This works well to ensure that /myfile.php works as well as just myfile (with no extension in the URL). It also handles querystrings with no problems, so myfile?var=foo also works. The problem is that these are registering in Google Analytics as being two separate files. So while myfile.php might be the third most

URL Rewriting - Redirect With No File Extension

假如想象 提交于 2021-02-07 19:45:45
问题 I am currently using the following rules in a .htaccess file: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php This works well to ensure that /myfile.php works as well as just myfile (with no extension in the URL). It also handles querystrings with no problems, so myfile?var=foo also works. The problem is that these are registering in Google Analytics as being two separate files. So while myfile.php might be the third most