Apache :: 2.2.15 - Rewrite Rules For Non-hosted Domain
Jul 1, 2015
CentOS 6. Apache 2.2.15
I am trying to redirect a request from a non-hosted domain, using a rewrite rule in our configuration file in conf.d. Our registrar has a pointer from this non-hosted domain to our domain.
With this whole no-www thing going on. I've decided to have a look at whether I can do this for my domains.
Instead of writing a
RewriteEngine On RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC] RewriteRule ^(.*)$ h77p://domain.com/$1 [R=301,L]
for every single domain I'd like to do this for across all domains as standard. I'm not too hot on rewrite rules and have in the past avoided them cos of the complexities. But I'd like to get this done, and no silently do it, but reflect the URL difference in the webbrowsers address bar too.
I am writing a rewrite rules using mod_rewrite module. I have the same data repeating all over the rules that I would like to replace with variable and set variable once at the top of rules then use variable in the rest of rules. Then if I need to add another IP address I would just add additional IP address to the variable instead like now need to change several rules.
For example I have IP addresses that I would like to set as a variable.
Now rules are the following (simplified) in httpd.conf:
RewriteEngine Off RewriteCond %{REMOTE_ADDR} (192.168.5.20|192.168.7.15|10.10.20.50
I'm kinda new to apache and I have the following situation.
I have a vps, on which I have set the following:
WordPress Site A, has it's own VirtualHost and domain WordPress Site B, has it's own VirtualHost and domain Canvas LMS (not connected to a domain). Canvas LMS can add multiple accounts, which may (or may not) be accessed individually using a URL that looks as follows:
{canvas_root}/accounts/{account_id}/
For example : http://....../accounts/4/
I need to add a link to each of WP sites, which points to each site's account on Canvas, such that it appears as .../learning/ folder
I do not want the users to see the /account/4/ , just /learning/ I also want to prevent accessing Canvas LMS is located beyond the website's DocumentRoot I want this to work with both HTTP and HTTPS
When I hit my server's domain it redirects me to one of the hosted sites' domain with a 302 redirect. It used to return the default plesk server page. How can I cancel the redirect?
I have a .fr domain purchased from Gandi.net. I have webhosting with GoDaddy.com.
After setting the DNS to point to GoDaddy.com (ns51 and ns52...) I get an error message and the DNS revert back to the default settings (gandi's DNS). AFNIC's(.fr regulator) zonecheck fails with the following error:
All will be hosted on the same server (same IP) and I want all to be secured, through a SIGNED certificate, not a self signed. I assumed that wildcard ssl would be fine for this, but I just took a look and it's only for subdomains: example.example.com hello.example.com.
Is there any way of having every subdomain and domain secured, using ssl, through one certificate? I don't want to have to buy individual certificates for every domain, that'd be... expensive.
I'm using a shared host that provides good service and support, but there's one major issue I discovered recently:
Other sites hosted on their server are accessible through my domains and subdomain. For example:
Account2 on their server can be accessed through:
[url] [url]
Host says:
"Because everything is Name-based, apache decides what directory is going to be used based upon the name that is provided. However, because the username is valid, it treats it as a vaild URL and redirects it to your site. There is no security issue, as this is just the way apache’s configuration works."
Is it really normal? Does the same happen on all apache servers? I think SE's would treat the other pages as mine, no?
We just moved a domain to a Canadian host. We want to make sure that the domain is actually hosted in Canada, how can we go about doing that? I thought of doing a standard traceroute, but usually the bandwidth is coming from the US, so at what point is it considered "Canadian hosted"?
I have all my specify modules are loaded in pache like mod_rewrite in other face I have a script need require mod_rewrite in install steps but I have in testing : Apache Mod-Rewrite Unavailable
On my website at www.jamescobban.net I have a directory which contains an ancient copy of my old static implementation of the site. It is there just in case someone has saved a old URL. However the data in that directory is several years out of date, so I would like to redirect the old static URLs to the equivalent dynamic URLs. For example: URLs.....
I wasn't warned that the <Directory> in the Apache conf file has to specify AllowOverride All whereas the default that is created when I install Ubuntu is AllowOverride None.I wasn't warned that I have to enable the mod_rewrite using a2enmod or else the rewrite commands are rejected.I am testing this on my private copy of the web-site where I can fiddle with options like that in the config file, but when I migrate this to my public server I do not have that privilege, so I want to try setting up the URL rewriting in .htaccess.
I would like to write a rewrite rule that does the following:
RewriteEngine On
Redirect 301 URL...
So what I want is that the first url is rewritten to go to the second ..I have a whole bunch of links that I have to redirect, so I would like to place them all into one .htaccess file or into the default configuration file of apache. So what I do not want is to create SomeFolder1 and someOtherFolder2 and to place a .htaccess file into that place in order to make it work. In fact I want to ignore the folders of the old link and only use the pagename.
I have some instructions written in the .htaccess of root directory for my website. So how to force those rules to apply to all sub directories even if those sub directories have .htaccess that overwrite the rules of the mother .htaccess on the root directory ? For example the root .htaccess deny access to all *.log files, so how to force that rule even if in some subdirectories there is some .htaccess files that allow access of *.log files.
i have a vps and although i can send mails without problem from my main root account, sending via any of the child accounts created for customers results in their email being picked up as spam (in hotmail at least).
To clarify, mydomain.com is my main name. Email can send without problem,
customersdomain.com, hosted on the same machine, when sending emails they are picked up as spam. The mx dns entries in the zone file are set (by default to) customersdomain.com. and for all the child domains customer1domain.com. etc.
Do i need to ask the datacenter to add a reverse dns entry for mail.mydomain.com?
Is this an issue with the mx records for the hosted domains? Should i change the hosted domaims mx entry on the customers domains to mail.mydomain.com?
I know the ip isnt blacklisted because exactly the same email goes through when sending from the mydomain.com email addresses.
I'm running Apache 2.4.4 Win32 on a Windows 2008 server. When trying to optimize a website I noticed a random reoccurring 2550ms delay in Time To First Byte. A file could have a TTFB of 200ms several times but suddenly it would get 2750ms. This could be a static file (image, html, js) or php. I've measured using ApacheBench (locally and remotely), webpagetest.org and bytecheck.com. After much trial and error I found the problem was with mod_rewrite. Disabling this and everything is fine.
I have setup a blank/new install with only basic config change (Listen, ServerRoot etc) to replicate result without anything else interfering. Following is the rewrite section I add to config.
Code: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule (^/Pictures.*) /$1 [L] </IfModule>
After Apache has started I execute "ab http://my.example.com/Pictures/Thumbnails/tmb_400X400_FFFFFF_660.jpg" and always get the delay. If I execute again it's normal. If I wait at least 30 seconds I get the delay. Following is a section from error.log with trace8 logging.
Code: [Tue Mar 12 23:28:56.123519 2013] [rewrite:trace3] [pid 7624:tid 888] mod_rewrite.c(468): [client 69.x.y.90:36279] 69.x.y.90 - - [my.example.com/sid#42c748][rid#26df0d0/initial] applying pattern '(^/Pictures.*)' to uri '/Pictures/Thumbnails/tmb_400X400_FFFFFF_660.jpg'
[Code] ....
As you see from line 3 to line 4 the time skips 2550ms. When the TTFB is normal then the log is identical except time doesn't change from line 3 to line 4. If I delete the rewrite section in config then TTFB is always normal, no matter what.
When I testet on the live server the time for fully loaded increase from 3800-4000ms to 8500-10500ms when mod_rewrite is enabled. And that is about 30 requests (php+css+js+images). So the impact is significant.
What can this be? I'm having a hard time believing it's a bug. Isn't mod_rewrite used a lot? I'm running Ubuntu (linux) at home, I'm going to install Apache there and see if I get the same result.
In my web site I have several index pages in different languages in the following format
[URL] ....
Two days ago I noticed increased, many times. Google bot activity on my site and when I checked my log file I found that all pages crawled were wrong web addresses: to the above index were added existing files from my site like
/folder1/folder2/file.html
So, the strings looked like
[URL] ....
And surprisingly all they returned code "200".
My question is: is there any way to rewrite such requests to the first ".html" found in the string.
I am trying to capture 3-4 digits when sent as part of a URL, for them to be proxied to another URL. I have no control over how the source sends this data, I am supposed to redirect it. Which works.
The problem is this works for all URLs that have digits to this server. I am expecting to trap URLs that send digits as part of the first call to the server, but this also affects URL calls that are part of other server call transactions, once digits appear, it gets redirected. What can I do to stop this interference?
I want to make it an internal rewrite though, not an external redirect. If I remove the [R=303] I still end up with a redirect (a 302). I assume mod_rewrite is forcing an external redirect because it's to a different [sub]domain.
Is there any way I can overcome this and make the change internal?