.htaccess

Conditional PHP Version in .htaccess

时光毁灭记忆、已成空白 提交于 2019-12-30 11:17:11
问题 On my local testing server I'm using PHP 5.4. On the live host, however, I'm currently limited to PHP 5.3 and it must be specified in .htaccess (otherwise it defaults to 5.2). So I can add: # Use PHP 5.3 Action application/x-hg-php53 /cgi-sys/php53 AddHandler application/x-hg-php53 .php which works great on the live host but breaks the local testing server. Is it possible to use something like mod_rewrite to conditionally specify a PHP version based on the domain? Or is there a better way?

Rewrite URL to index.php but avoid index.php in the URL

↘锁芯ラ 提交于 2019-12-30 11:14:10
问题 I'm trying to internally redirect all requests to index.php and externally redirect all requests that contain index.php using a .htaccess file. So URLs like http://host/test should be processed by index.php and URLs like http://host/index.php/test should be redirected to http://host/test and then processed by index.php (without redirecting the browser to index.php) I tried the following but always get a message "Too many redirects...": RewriteRule ^index\.php/?(.*)$ /$1 [R,L] RewriteRule .*

HTTPS only on specific page with .htaccess

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 11:09:20
问题 I have a URL such as http://www.domain.com/index.php?p=register . I want to redirect that to use HTTPS (SSL) with .htaccess, but only on this, and a couple of other pages (the login page, etc), but not the entire site. The URLs don't point to directories, but are used to dynamically include different files. Can someone give me a pointer or an example of how to get a single page redirect to HTTPS please? Thanks. 回答1: Not htaccess, but another way could be to use PHP to redirect: <?php

htaccess reverse directory

馋奶兔 提交于 2019-12-30 11:06:57
问题 It is possible to let htaccess look for a specific file related to the url and go back one step if not found? Example: /example/here/where/from Htaccess looks if the '/example/here/where/from' is indeed a file of some sort(/example/here/where/from.php) if this fails it goes back one step and checks if ' '/example/here/where' is a file(/example/here/where.php) and so forth. If it had to go back in the tree assume them as parameters as in: /example/here.php $_GET['params'] = 'where/from';

Query string redirection with htaccess

こ雲淡風輕ζ 提交于 2019-12-30 10:30:13
问题 On a website I'm working on now I need to set up a redirection that takes a query string into consideration. Example: http://www.domain.com/?id=86&name=John&ref=12d34 -> http://www.domain.com/?ref=12d34 http://www.domain.com/?ref=593x56&id=935 -> http://www.domain.com/?ref=593x56 http://www.domain.com/?ref=3v77l32 -> http://www.domain.com/?ref=3v77l32 So basically I need to find the ref parameter and it's value (whatever it's length) and append only that part to the new URL. The issue is the

Cleaning up nested mod_rewrite statements

坚强是说给别人听的谎言 提交于 2019-12-30 10:18:27
问题 I am cleaning up a large .htaccess file containing a lot of mod_rewrite statements. The biggest part of the clutter comes from statements catching various occurrences of /directory1 /directory1/directory2 /directory1/directory2/directory3 using statements like RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)$ RewriteRule .* /front.php?level1=%1&level2=%2&%{QUERY_STRING} [L] RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/]+)/([^/]+)$ RewriteRule .* /front.php?level1=%1&level2=%2&level3=%3&%{QUERY_STRING

Using custom environment variables in .htaccess

烂漫一生 提交于 2019-12-30 10:14:20
问题 I need something like this: SetEnv foo bar.baz RewriteEngine On RewriteCond %{HTTP_HOST} ^%{foo}$ RewriteRule ^(.*)$ http://www.foo/$1 [L] UPD: I have made as follows: SetEnv HOSTNAME_ENV testsite RewriteEngine On RewriteCond %{HTTP_HOST} ^%{ENV:HOSTNAME_ENV} RewriteRule ^(.*)$ http://www.%{ENV:HOSTNAME_ENV}/$1 [L,R=301] But it doesn't work. %{ENV:HOSTNAME_ENV} is not defined. 回答1: This won't work, because mod_rewrite does not expand variables in test patterns. Consequently, your expression

mod-rewrite redirect but prevent direct access

北慕城南 提交于 2019-12-30 09:59:53
问题 I want to redirect all content to: www.example.com/public/... but prevent direct access to www.example.com/public/file1/ www.example.com/public/file2/ etc The final URL should be: www.example.com/file1/ I've tried this for redirecting and it works - but I dont know how to prevent direct access: ReWriteCond %{REQUEST_URI} !/public/ RewriteRule ^(.*) public/$1 [L] 回答1: After spending an inordinate amount of time trying to solve this problem, I found that the solution lies with the under

Using htaccess rewrite/redirect so single PHP file can display data according to GET/POST variables

谁说胖子不能爱 提交于 2019-12-30 09:35:17
问题 Bear with me as I try to learn more about .htaccess redirect rules - I'm a UI guy by profession and I'm doing my best to enhance my coding skills languages other than HTML/CSS/PHP, etc So, what I have is an index.php file that contains a menu - pretty simple. If Javascript is enabled on the users computer then forms are shown below the menu using simple jQuery goodies, with each link having a 'return false;' applied. What I am trying to do is make the page accessible with JS turned off, so

mod_rewrite problem with relative path css/js

心已入冬 提交于 2019-12-30 08:53:39
问题 Hi I have a problem. I want to get all requests to redirect to index file in main directory and I've achieved this but there are problems with relative paths. When I put address like: mydomain.com/something it works ok as the paths are relative to the main directory. The problem is when I put something like: mydomain.com/something/somethingelse. the .htaccess file: Options FollowSymLinks RewriteEngine On # ignore anything that's an actual file RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f #