mod-rewrite

Heroku (PlayFramework/Scala) app automatically redirect to https

房东的猫 提交于 2020-01-06 07:25:38
问题 I have an PlayFramework App developed using Scala running on Heroku; I only mention the development language and framework because any posts I've found regarding this issue relate to PHP! I have http and https running on a custom domain but I would like to force http requests to be redirect to https. I've found that I need to update the .htaccess file with the following: ##Force SSL #Normal way (in case you need to deploy to NON-heroku) RewriteCond %{HTTPS} !=on #Heroku way RewriteCond %{HTTP

Reference: mod_rewrite, URL rewriting and “pretty links” explained

痴心易碎 提交于 2020-01-06 07:09:27
问题 "Pretty links" is an often requested topic, but it is rarely fully explained. mod_rewrite is one way to make "pretty links", but it's complex and its syntax is very terse, hard to grok, and the documentation assumes a certain level of proficiency in HTTP. Can someone explain in simple terms how "pretty links" work and how mod_rewrite can be used to create them? Other common names, aliases, terms for clean URLs: RESTful URLs, user-friendly URLs, SEO-friendly URLs, slugging, and MVC URLs

Why does this .htaccess RewriteRule that includes a '#' fail?

▼魔方 西西 提交于 2020-01-06 07:07:19
问题 Goal: Match URL and rewrite it to a query string. Problem: Looks like the "#" (and everything after it) in the replacement string is being ignored. Here's what I have: RewriteEngine On RewriteRule ^([^\.]+)$ $1.html [NC,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+) web2.html#list?d=$1&n=$2 [L,NE] This gets to web2.html but the url parameters ( d= & n= ) are never applied. The goal is to allow a url like: somewehere.com

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

Secretly do a mod_rewrite on domain name

喜你入骨 提交于 2020-01-06 06:45:07
问题 I'm struggling with a mod_rewrite problem. Basically I need to do a secret redirect on the domain name, going from http://domainname.com.someotherstuff.com to http://domainname.com This rule should affect all subdirectories as well. I've understood there are three steps: tell the system if the path matches what we're looking for define the RewriteRule pass the new path to the old one so that the system knows (even if it doesn't show) that the two match I've looked up several posts and

Mod Rewrite: Handling two Get Variables

主宰稳场 提交于 2020-01-06 06:44:32
问题 How can I edit this url rewrite to include a further get variable being appended to the URL? I have tried a few attemps but I always get a 500 internal server error! I have added comments to show what I am trying to achieve. # /view.php?user=h5k6&page=1 externally to /h5k6/1 # Some times the page get variable will not exist so it should just show /h5k6 RewriteCond %{THE_REQUEST} ^GET\ /view\.php RewriteCond %{QUERY_STRING} ^([^&]*&)*user=([^&]+)&?.*$ RewriteRule ^view\.php$ /%2? [L,R=301] #

Mod_rewrite .htm to fake subdirectory

二次信任 提交于 2020-01-06 06:36:37
问题 I have a website with a CMS that uses mod_rewrite to make URLs look cleaner. Previously, the clean URLs had the extension .htm, but I want to transition this to them appearing as fake subdirectories, IE: http://www.example.com/pagename/ I have two rewrite rules in place to rewrite both the old scheme and the potential new one: RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+).htm$ index.php?page=$1 [QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ index.php?page=$1 [QSA] My

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)){

Pretty URL - mod_rewrite question

我们两清 提交于 2020-01-06 05:48:05
问题 I'm trying to setup a simple mod_rewrite for formatting "pretty URLs". All I need is for something like: http://www.example.com/dir1/dir2/logs?page=12 to tranlate to http://www.example.com/logs/12 How would my .htaccess rule look like? 回答1: RewriteRule ^/logs/(\d+)$ /dir1/dir2/logs?page=$1 来源: https://stackoverflow.com/questions/3654859/pretty-url-mod-rewrite-question

Change appearance of URLs with htaccess mod_rewrite RewriteRule

一个人想着一个人 提交于 2020-01-06 05:35:28
问题 It's really tough to find clear explanations of the Rewrite Engine syntax anywhere. Regular expressions are familiar, but the rest of it is alien to me. Is there no way to hide http:// or https:// in the URL that is displayed in the address bar? My directory looks like this. public_html/ example/ index.php whatever.php Issue #1 This is currently what's happening, which obviously all over the place. URL THAT IS TYPED IN URL THAT DISPLAYS https://www.example.com -------------------> https://www