mod-rewrite

Logging mod_rewrite on Apache 2.2

淺唱寂寞╮ 提交于 2019-12-12 01:32:31
问题 I am trying to troubleshoot mod_rewrite on Apache2.2.15 operating on Centos 6.5. My httpd.conf file is as follows: <VirtualHost *:80> ServerName somesite.com DocumentRoot /var/www/somesite/html <Directory "/var/www/somesite/html"> <IfModule mod_rewrite.c> RewriteEngine On RewriteLog /var/log/httpd/rewrite.log RewriteLogLevel 3 </IfModule> </Directory> </VirtualHost> I keep on getting the following error where line 1044 corresponds to RewriteLog /var/log/httpd/rewrite.log . [root@devserver

Rewrite all URLs to a new domain and include an extra parameter

萝らか妹 提交于 2019-12-12 01:28:41
问题 Which .htaccess redirect rule(s) would one use to create all of the following forwards? http://old.io --> http://new.com?pa=va http://old.io/ --> http://new.com/?pa=va http://old.io/abc --> http://new.com/abc?pa=va http://old.io#def --> http://new.com#def?pa=va http://old.io/abc#def --> http://new.com/abc#def?pa=va . . . and include any other arbitrary parameters: http://old.io?p2=v2 --> http://new.com?pa=va&p2=v2 http://old.io/?p2=v2 --> http://new.com/?pa=va&p2=v2 http://old.io/abc?p2=v2 --

How to use wildcard subdomain in a folder on server public_html/subdomain

帅比萌擦擦* 提交于 2019-12-12 01:26:33
问题 I have a wildcard subdomain in a folder public_html/subdomain on my server. I am using php script as follows Just to show you what I am doing on the page: <?php $subdomain = explode('.', $_SERVER['HTTP_HOST']); $subdomain = strtolower(array_shift($subdomain)); echo ucwords(str_replace('-', ' ', $subdomain)); ?> The problem is when example.domain.co.uk is typed in it returns the top level public_html/index.php file and not the public_html/subdomain/index.php I had this working before but I may

.htaccess SSL redirect with url rewrite

ぐ巨炮叔叔 提交于 2019-12-12 01:24:14
问题 I need your help. Let's say this is my website: example.com I would like to redirect http to https. Furthermore I would like also rewrite the url. If i access the website with: https://example.com/new everything is working fine. If I access the website with: http://www.example.com/new it redirects to https but will not rewrite the url. The result is this: `https://example.com/old` RewriteEngine on RewriteRule ^new/(.*)$ old/$1 [L,QSA] RewriteCond %{HTTPS} =off [NC,OR] RewriteCond %{HTTP_HOST}

htaccess rewrite to remove query string

给你一囗甜甜゛ 提交于 2019-12-12 01:20:52
问题 I need to rewrite the following: http://www.mystuff.com/drinks/category/beer?page=1 to https://www.mystuff.com/food-drink/beer/ale No matter what I try the URI rewrite to the new address but it keeps the query string attached. I need to lose this. I've tried so many options and none seem to work, can anybody ofgfer some advice. I thought this would do it, but no: RewriteCond %{QUERY_STRING} (.*)(?:^|&)page=(?:[^&]*)((?:&|$).*) RewriteCond %1%2 (^|&)([^&].*|$) RewriteRule ^(/drinks/category

using mod_rewrite to change url path

天大地大妈咪最大 提交于 2019-12-12 01:18:59
问题 Is it possible to make a folder transparent in the URL like in the following example: example.com/test/ changed to example.com/ using mod_rewrite? I like having folders for organization, but I want a nice clean url. 回答1: You can achieve that with mod_rewrite putting something like this in the .htaccess file of your root folder: RewriteEngine on # the first condition is for avoiding an infinite loop RewriteCond %{REQUEST_URI} !^/test/.* RewriteRule ^(.*)$ /test/$1 This will redirect to /test/

mod_rewrite: match only if no previous rules have matched?

筅森魡賤 提交于 2019-12-12 01:17:01
问题 I've got a large set of rewrite rules like the following: RewriteRule ^foo foo.php?blah [L] RewriteRule ^bar foo.php?baz [L] And then I have a sort of catch-all rule that I want to only apply if the above rules don't match (e.g. for, say /blatz ). As long as I remember to include the [L] , that works fine -- but I've already had issues twice with accidentally forgetting it. Is there any easy way to to force my catch-all rule to not match if an earlier rule has matched? (ideally, without

.htaccess sexy url rewrites

我只是一个虾纸丫 提交于 2019-12-12 01:14:17
问题 I want to get all my domains to rewrite and look good. for example: example.com/blog.php?article=the-name-of-article to become example.com/blog/the-name-of-article so i want the .php?article= to be changed into a / my current .htaccess file looks like: Options +FollowSymLinks -MultiViews rewriteengine on RewriteBase / ## Hide .php extension ## To externally redirect /dir/foo.php to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L,NC] ## To internally

.htaccess redirect any subdomain *.domain1.com to *.domain2.com

╄→гoц情女王★ 提交于 2019-12-12 01:08:24
问题 I want to redirect every subdomains of domain1.com to domain2.com foo.domain1.com -> foo.domain2.com baz.domain1.com -> baz.domain2.com bar.domain1.com -> bar.domain2.com etc 回答1: https://stackoverflow.com/a/8046069/2024688 RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain1\.com$ [NC] RewriteRule ^(.*)$ http://%1%2.domain2.com/$1 [L,R] 来源: https://stackoverflow.com/questions/17141021/htaccess-redirect-any-subdomain-domain1-com-to-domain2-com

.htaccess basic url rewrites

心已入冬 提交于 2019-12-12 01:07:54
问题 There are a few things I want done to the URLs of my site that I cannot seem the .htaccess file to do. 1 remove file extension f.e. example.com/file.php should be example.com/file 2 remove the www. f.e. www.example.com should be example.com (I got this part to work, but I would hate it if after I put in fix and this no longer worked 3 no one should be able to see index.php at the end of root f.e. example.com/index.php should be example.com 4 my blog page should have nice urls f.e. example.com