mod-rewrite

HTACCESS Redirect all domain except two files

半城伤御伤魂 提交于 2019-12-21 04:29:09
问题 My actual htaccess redirect my complete old site to my new site, I want to redirect all domain but except two file .php (protectetfile1.php and protectedfile2.php). This is my htaccess RewriteEngine On Rewritecond %{http_host} ^olddomain.org [NC] Rewriterule ^(.*)$ http://newdomain.net/$1 [L,R=301] 回答1: Use this rule: RewriteEngine On Rewritecond %{http_host} ^olddomain\.org [NC] RewriteCond %{REQUEST_URI} !/(protectetfile1|protectetfile2)\.php [NC] Rewriterule ^(.*)$ http://newdomain.net/$1

Setting up Wildcard subdomain (with reverse proxy) on apache 2.2.3

百般思念 提交于 2019-12-21 04:17:33
问题 What I am trying to achieve is the following: I want to have numerous subdomains such as abc.domain.com redirect to a url such as www.domain.com/something?subdomain=abc Since I am redirecting to a fully qualified domain, I needed to use a reverse proxy to avoid the change of the URL in the browser. (using the [P] Flag and turning on the mod_proxy module and some other modules) This is my DNS setup *.domain.com. 14400 A 111.111.11.1 This is my virtual host configuration for apache <VirtualHost

.htaccess in Multiple Environments

﹥>﹥吖頭↗ 提交于 2019-12-21 03:36:25
问题 I know similar questions have been asked before but I haven't found any really specific answers for my situation. I have an ExpressionEngine site running on multiple environments (local, dev, production), and each of those environments needs different .htaccess rules: All Environments Remove index.php Set a 404 file Set 301 Redirects Development Password Protect with .htpasswd Force HTTPS protocol Prevent search engine indexing with X-Robots-Tag Production Force HTTPS protocol Redirect non

Can't configure the rewrite log

允我心安 提交于 2019-12-21 03:23:13
问题 I'd like to enable the rewrite log to debug some rewrite rules that are giving me problems. So I added these lines at the end of my httpd.conf file: <IfModule mod_rewrite.c> RewriteLog "/logs/rewrite.log" RewriteLogLevel 4 </IfModule> Next thing I did was restart Apache. It causes an error however, and won't start. This is what I get in the XAMPP Control Panel: 13:14:56 [Apache] Error: Apache shutdown unexpectedly. 13:14:56 [Apache] This may be due to a blocked port, missing dependencies, 13

Security: Deny access to .hg/* via mod_rewrite

房东的猫 提交于 2019-12-21 02:35:09
问题 My website is a mercurial repository with multiple subrepositories. I need to make sure I'm denying access to all files in every .hg directory on the server. For example, I have http://example.com/.hg/ and http://example.com/subrepo1/.hg/ I've added the following to .htaccess: <Files ~ "^\.(hg|ht)"> Order allow,deny Deny from all </Files> This is a good start, as it denies access to files beginning with .hg and .ht , but it doesn't deny access to the files inside .hg directories, so if

Do HTTP authentication over HTTPS with URL rewriting

好久不见. 提交于 2019-12-20 23:24:22
问题 I am trying to protect the ~/public_html/dev directory using http auth basic, but to make that secure I want to run it over ssl. The middle section of the below .htaccess file switches to https if the request URI begins with /dev and works. The last section of the file works as well but does not work properly with the https redirect. I basically want to be able to type http://www.example.com/dev/some_sub_dir/ and be redirected to https://www.example.com/dev/some_sub_dir/ and prompted for the

mod_rewrite VS relative paths

风格不统一 提交于 2019-12-20 14:35:57
问题 My mod_rewrite code is: Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.+)?$ index.php?url=$1 [L,NC] This structure is placed on my server path /beta When I place the URL http://mydomain.com/beta/download everything works rewriting to the real path http://mydomain.com/beta/index.php?url=download The problem happens with the relative paths. When I enter the URL http://mydomain.com/beta/download/box

How to dynamically redirect www-based URLs to non-www URLs with multiple domains in same VirtualHost

岁酱吖の 提交于 2019-12-20 12:41:06
问题 I've got a VirtualHost that looks something like: <VirtualHost *:80> ServerName domain1.com ServerAlias www.domain1.com domain2.com www.domain2.com </VirtualHost> When someone visits www.domain1.com/test, they should be redirected to: domain1.com/test When someone visits www.domain2.com/test, they should be redirected to: domain2.com/test My current RewriteRules are lacking. Edit: Here's what I've got so far: # Rewrite www to non-www RewriteEngine on RewriteCond %{HTTP_HOST} www\.%{HTTP_HOST}

Conditionally setting cache headers in apache

感情迁移 提交于 2019-12-20 12:22:32
问题 I want to conditionally set cache headers depending on what path files are accessed from. Basically, accessing http://www.example.com/cache/$cache_key/* should serve files with far in the future cache headers. I'm using a rewrite rule to set an environment variable and then attempting to set cache control headers based on that variable. However, it seems like the variable is being set too late in the process or something; the conditional header rules are never getting executed. RewriteRule

Conditionally setting cache headers in apache

痴心易碎 提交于 2019-12-20 12:22:12
问题 I want to conditionally set cache headers depending on what path files are accessed from. Basically, accessing http://www.example.com/cache/$cache_key/* should serve files with far in the future cache headers. I'm using a rewrite rule to set an environment variable and then attempting to set cache control headers based on that variable. However, it seems like the variable is being set too late in the process or something; the conditional header rules are never getting executed. RewriteRule