Forum Moderators: phranque
About a week ago I converted my main site from shtml files to php. I used url rewrite to redirect old links to the correct, new files, but it seams to have affected my subdomain...it now directs to my main site.
Is there something I can add to the htaccess file in the subdomain directory to make it dissregard the htaccess file in the root directory?
RewriteEngine Off has no affect.
I can post the contents of the root .htaccess file, if needed.
Thanks!
subdomain: [sub.domain.com...]
ends up at...
main site: [domain.com...]
Jim
That's it. I'm sure it is my lack of knowledge about this...
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^subdomain\.domain\.com
rewriterule (.*) [domain.com$1.php...] [R=permanent,L]
says if not asking for subdomain.domain.com, then
redirect according to rewriterule
RedirectMatch 301 (.*)\.shtml$ http://www.example.com$1.php
RedirectMatch journal/archives/(.*) http://www.example.com/journal/archives.php
Redirect permanent /phpBB/index.php http://www.example.com/phpBB2/index.php
Redirect permanent /forum/ http://www.example.com/phpBB2/
Redirect permanent /phpBB/ http://www.example.com/phpBB2/
RedirectMatch permanent ^/design/index.html$ http://www.example.com/design/index.php
Redirect permanent /gallery_hostas_01.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_02.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_03.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_04.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_05.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_06.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_07.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_hostas_landscape_01.php http://www.example.com/gallery/hostapictures
Redirect permanent /gallery_pond_01.php http://www.example.com/gallery/pondpictures
Redirect permanent /gallery_pond_02.php http://www.example.com/gallery/pondpictures
Redirect permanent /gallery_pond_03.php http://www.example.com/gallery/pondpictures
Redirect permanent /gallery_pond_04.php http://www.example.com/gallery/pondpictures
Redirect permanent /christmas2001.shtml http://www.example.com/christmas.php
Redirect permanent /christmas2002.shtml http://www.example.com/christmas.php
Redirect permanent /christmas2003.shtml http://www.example.com/christmas.php
Redirect permanent /christmas2004.shtml http://www.example.com/christmas.php
Redirect permanent /xmasnewsletter2001.shtml http://www.example.com/xmasnewsletter2001_2.php
Redirect permanent /xmasnewsletter2001.php http://www.example.com/xmasnewsletter2001_2.php
Redirect permanent /xmasnewsletter2002.php http://www.example.com/xmasnewsletter2002_2.php
Redirect permanent /xmasnewsletter2002.shtml http://www.example.com/xmasnewsletter2002_2.php
ErrorDocument 404 /404.php
<Limit GET>
Order Allow,Deny
Allow from all
Deny from example.net
</Limit>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 200.**.19.98
# <snip>
deny from 68.**.56.132
php_value zend_optimizer.optimization_level 14
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR]
RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR]
RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR]
RewriteCond %{HTTP_USER_AGENT} ^Custo [OR]
RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR]
RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR]
RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR]
RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR]
RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR]
RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR]
RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR]
RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR]
RewriteCond %{HTTP_USER_AGENT} ^HMView [OR]
RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR]
RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR]
RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR]
RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR]
RewriteCond %{HTTP_USER_AGENT} ^larbin [OR]
RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR]
RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR]
RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR]
RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR]
RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR]
RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR]
RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR]
RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR]
RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR]
RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR]
RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR]
RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR]
RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR]
RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR]
RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR]
RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR]
RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR]
RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR]
RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR]
RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR]
RewriteCond %{HTTP_USER_AGENT} ^Wget [OR]
RewriteCond %{HTTP_USER_AGENT} ^Widow [OR]
RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
I'm sure there are many mistakes!
[edited by: jdMorgan at 5:41 am (utc) on Dec. 8, 2005]
[edit reason] Removed/obscured specific IPs, examplified. [/edit]
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^subdomain\.example\.com
RewriteRule (.*) http://www.example.com/$1.php [R=301,L]
Jim
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
I get this for the main and sub domains.
And the urls look like this:
main: www.domain.com/.php.php.php.php. (and on and on...)
sub: www.domain.com/index.php.php.php.php. (and on and on...)
In this case, failing to find a page at sub.domain.com, mod_dir on the server generates a redirect which may be kicking it over to www.domain.com instread of sub.domain.com.
Try explicitly declaring your directory index page by adding
DirectoryIndex index.php
I'm not sure that will help, but it's the only thing I can think of. Otherwise, I'd suggest you contact your host and ask them why a specific URL in the subdomain is getting redirected to the main domain. If they can't help, then ask them to please e-mail you the httpd.conf file for the server (they'll want to remove the confing info for all other sites hosted on that server if it's shared, but that's fine).
Something's not right with your configuration, but it's hard to tell what without access to the config file.
Jim
I have a slightly different version of the problem you were able to sort out for JoshS. Hope you can tell me where I'm going wrong please.
I have a sub-domain (subdomain-b/mydomain.co.uk) that I want to re-direct to another domain (domain-b.co.uk).
Have tried the following but it doesn't work.
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} ^subdomain-b\.mydomain\.co\.uk
RewriteRule (.*) [domain-b.co.uk...] [R=301,L]
Any advice you can give will be appreciated.
Thanks very much.
1) Is this code located in a directory-path that will be accessed when the subdomain is requested? If not, then it can have no effect. (If you have defined the subdomain using a "control panel" then it is likely that you'll need to move this code into an .htaccess file in the subdirectory created by the control panel to house the files for the subdomain.)
2) Do you have other working rewriterules in the same .htaccess file? If so, then that proves that your server is configured to process mod_rewrite code.
Other than that, I can't think of anything else without knowing more about specifically how "it doesn't work."
Jim
I didn't have the .htaccess file in the subdirectory which contains the files used by the subdomain. So have copied the .htaccess file & moved it there as you advised. However still no joy. (Path to directory with subdomain files being: /var/www/directory)
By it 'not working' what I meant is that [subdomain-b...] doesn't re-direct to www.domain-b.co.uk which is what I'm trying to achieve. Instead the site is presented with the URL [subdomain-b...]
To answer the other point you raised. Yes, I do have other rewrite rules working in the same .htaccess file? So that proves the server is configured to process mod_rewrite code.
One thing I didn't mention is that its a site that uses FrontPage extensions, so not sure if that's a factor.
Would it help to sticky you the actual htaccess file?
Thanks.
In order for a site using FrontPage extensions to work with mod_rewrite, you must place the directive
Options +FollowSymLinks
It replaces the directive
Options None
The FollowSymLinks option is required to enable mod_rewrite in each subdirectory.
As pointed out in another recent thread [webmasterworld.com], using PHP or SSI to replace FrontPage extensions would make your life easier on an Apache server.
Jim