[SOLVED] ErrorDocument Redirection

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

[SOLVED] ErrorDocument Redirection

Post by anjanesh »

http://localhost/mysite

In mysite's .htaccess I have

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [NC]
ErrorDocument 404 index.php
But instead of going to index.php it just outputs index.php
If I replace ErrorDocument 404 index.php with ErrorDocument 404 /index.php it shows http://localhost/index.php and not http://localhost/mysite/index.php

Any idea how to fix this ?

Thanks
Last edited by anjanesh on Sun Sep 11, 2005 12:58 pm, edited 1 time in total.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: ErrorDocument Redirection

Post by josh »

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [NC]
ErrorDocument 404 /mysite/index.php

???
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

I want to give the relative path, index.php in mysite directory not ErrorDocument 404 /mysite/index.php after all the .htaccess file is in mysite directory.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

./index.php ?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Displays ./index.php and nothing more - doesnt not load http://localhost/mysite/index.php - using APache on Widnows BTW.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use mod_rewrite then for this :)
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

On my localhost this works (http://localhost/myfolder/a.html)

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost
RewriteRule ^([\w\d\-]+)\.html$ index.php?a=$1
But when copied to my site with a few changes it doesnt - returns 404 (http://www.mysite.com/myfolder/a.html)

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule ^([\w\d\-]+)\.html$ index.php?a=$1
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

rewrite condition wasn't met. You're looking for mysite.com at the beginning of the value. If you want to support subdomains, it must be more like mysite\.com$
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Not a subdomain.
I replaced \w\d\- with a-zA-Z0-9\- and it worked !
I dont understand why \w\d\- works on my localhost and not on site !
My PC : Apache 2.0.52
Site : Apache 1.3.33
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

different versions of regex support. Those are VERY different servers these days...
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Ah...Thanks.
Post Reply