url-rewriting

why does the regex in my rewrite condition seem to not catch?

余生长醉 提交于 2020-01-07 08:07:49
问题 I have URLs like the following: mysite.com/eng?sentence=dog and I want to rewrite them as mysite.com/eng/dog so I want to replace ?sentence= with a "/" I have tried all of the following: RewriteCond %{THE_REQUEST} ^GET\ sentence= [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\ \?sentence= [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\ \?sentence=([^/?&\s]+) [NC] RewriteRule ^ /%1 [NC,L,NE] RewriteCond %{THE_REQUEST} ^GET\s/+\?sentence=([^/?&\s]+) [NC]

Redirect existing file to different url using mod_rewrite

安稳与你 提交于 2020-01-07 04:28:09
问题 I'm trying to use mod_rewrite to redirect an existing file to a different URL. I'm using the following and it has no effect. I've tried several variations of which don't work. RewriteEngine on AddHandler x-httpd-php .php3 # AddHandler x-httpd-php5 .php .php4 # This file exists, but this redirect doesn't work RewriteRule ^show.php?id=review-1$ /review/1/super-baseball-2020/ [R=301,L] Does it by chance have something to do with the url params? 回答1: You cannot have query string in RewriteRule.

nginx rewrite url removing subfolder

偶尔善良 提交于 2020-01-07 02:48:06
问题 I am struggling a bit with rewriting some urls in nginx I have a site: foo.com/ foo.com/index.html has a link to foo.com/bar.cgi (maybe with with GET arguements) my cgi resides in /var/www/site/cgi-bin/ and thus it is accesible via foo.com/cgi-bin/bar.cgi I was hoping the rewrite would remove the cgi-bin part location ~ \.cgi$ { root /var/www/localhost; #rewrite ^/cgi-bin/(.*)$ $1 permanent; fastcgi_param SCRIPT_FILENAME/ /var/www/localhost$fastcgi_script_name; include /etc/nginx/fastcgi.conf

SilverStripe 3.1+ Dynamically creating page redirects

空扰寡人 提交于 2020-01-07 02:01:13
问题 I have a page type 'ProductPage', it has tabs that are navigated to like so: /ProductPageUrlSegment/?tab=video /ProductPageUrlSegment/?tab=audio /ProductPageUrlSegment/?tab=photos I'd like for redirects to be created when each new product page is created so that if you navigated /ProductPageUrlSegment/video it goes to /ProductPageUrlSegment/?tab=video and the same for all tabs. I'm not clear if I should be using Routing https://docs.silverstripe.org/en/3.3/developer_guides/controllers/routing

Apache - Rewrite dynamic subdomains and URL parameters

蓝咒 提交于 2020-01-06 18:06:33
问题 I have a problem with rewrite condition and rule in Apache2. I want to have dynamic subdomains and dynamic folders, which will rewrite to php script. For example: sub1.example.com/folder1 => do.php?a=sub1&b=folder1 sub2.example.com/folder2 => do.php?a=sub1&b=folder2 It will looks like every subdomain has own folders. But some subdomain (admin etc) will not be rewrited. I know how to rewrite subdomain: RewriteEngine On RewriteCond %{HTTP_HOST} ^(^.*)\.example.com/ [NC] RewriteRule ^(.*)$ do

Drupal hook_url_inbound_alter not altering my url

寵の児 提交于 2020-01-06 17:09:07
问题 I have in my module named 'categorie' a implementation of: function categorie_url_inbound_alter(&$result, $path, $path_language) { if ($path == 'e') { $result = 'user'; } } I'm planning to do something a bit more advanced but I can't even seem to get the basic one working. With this implementation I expect that if a user goes to mysite.com/e , he gets the user page. But I'm getting a 404. In this topic:Using module: url_alter and it's hook: hook_url_outbound_alter() they also suggested you

Remove part of URL with RewriteRule

你说的曾经没有我的故事 提交于 2020-01-06 15:03:37
问题 I need remove prefix /en from all URL, eg. www.mydomain.com/en/foo/bar/index.html -> www.mydomain.com/foo/bar/index.html I've tried with: RewriteRule ^/en/(.*) /$1 [L] or RewriteRule ^/en/\d+-(.+) /$1 [R,L] but nothing happens 回答1: You can use in your .htaccess : RewriteEngine on RewriteRule ^en/(.*) /$1 [NC,L] Because in .htaccess , RewriteRule first URL never starts with / 来源: https://stackoverflow.com/questions/32332624/remove-part-of-url-with-rewriterule

How to rewrite this URL to a redirect page?

↘锁芯ラ 提交于 2020-01-06 08:24:12
问题 I am using Microsoft-IIS/7.5 on a hosted server (Hostek.com) I have an existing site with 2,820 indexed links in Google. You can see the results by searching Google with this: site:flyingpiston.com Most of the pages use a section, makerid, or bikeid to get the right information. Most of the links look like this: flyingpiston.com/?BikeID=1068 flyingpiston.com/?MakerID=1441 flyingpiston.com/?Section=Maker&MakerID=1441 flyingpiston.com/?Section=Bike&BikeID=1234 On the new site, I am doing URL

Changes to RewriteRule in .htaccess not taking effect

廉价感情. 提交于 2020-01-06 07:01:02
问题 I had this rewrite rule set up in .htaccess and it was all working fine... Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteCond %{REQUEST_URI} ^/mypage(.*)$ [NC] RewriteRule ^(.*) http://example.com/PHProxy/poxy-0.5b2/index.php?url=http://example.org/mypage [L,R=302,NC] However, when I change the url in the RewriteRule to http://example.com/PHProxy/poxy-0.5b2/index.php?url=http://example.org/mypage it still redirects to the old URL. After some research, I added a syntax error into

Rewrite url with 2 or more params

微笑、不失礼 提交于 2020-01-06 05:49:13
问题 I asked a question like this before but since i still can't find an answer to this i'll ask it again :-s. I'm using this very basic 'templating' script: require_once 'core/init.php'; if(empty($_GET['page'])){ header('Location: home'); die(); } $basePath = dirname(__FILE__) . '/'; $viewPath = $basePath . 'view/'; $view = scandir($viewPath); foreach($view as $file) { if (!is_dir($viewPath . $file)) { $pages[] = substr($file, 0, strpos($file, '.')); } } if(in_array($_GET['page'], $pages)){