Forum Moderators: phranque

Message Too Old, No Replies

Rewritecond problem

Rewritecond problem

         

webstyler

11:22 am on Mar 26, 2005 (gmt 0)

10+ Year Member



Hi :)

I have 1 no-ip account
When client go on [example.no-ip.com...]
arrive on my local machine
I need to "redirect" people that come from there into a dir specific

So, I have write this on my .htaccess file :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.no-ip.com.*
RewriteRule ^/$ /mydir/myfile.php [L]

BUT return Internal Server Error..

why? :(

sitz

3:43 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



At a guess, mod_rewrite isn't enabled in the server. In order for it to work, the module has to be loaded and the FileInfo option needs to be set for the AllowOverride directive used for the directory in which you have your .htaccess. For example, if your directory is:

/usr/local/apache/domains/example.no-ip.com/

Somewhere in the httpd.conf there would need to be something like:

<Directory /usr/local/apache/domains>
(bunch of other directives)
AllowOverride FileInfo (likely some other overrides)
</Directory>

webstyler

4:35 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



:(

I have add the string indicated but I get always error

Birdman

5:06 pm on Mar 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

The period is a reserved character for regular expressions. If you need to match a reserved character literally, you need to escape it .

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.no-ip\.com
RewriteRule ^/$ /mydir/myfile.php [L]

sitz

9:14 pm on Mar 26, 2005 (gmt 0)

10+ Year Member



the period wouldn't cause a 500 error, tho. That generally implies that the .htaccess file is misconfigured. The good news is that if you have write access to the httpd.conf file, you also have *read* access to Apache's error log; it should contain details on the precise nature of the error.

webstyler

3:19 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



I have try this :
----

<Directory />
Options FollowSymLinks
AllowOverride FileInfo
</Directory>

----this :----

<Directory "C:/Web" />
Options FollowSymLinks
AllowOverride FileInfo
</Directory>

----and this----

<Directory C:/web/>
Options FollowSymLinks
AllowOverride FileInfo
</Directory>

not to all :(

jdMorgan

3:31 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post the contents of your server error log. If you are getting a 500-Server Error, the error log file should contain one or more error messages relevant to the problem. Sometimes, it will tell you exactly what is wrong.

Jim

webstyler

3:54 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



for time to my lost access error.log report this :
[Sun Mar 27 17:17:10 2005] [alert] [client 81.74.98.19] c:/web/.htaccess: Options not allowed here

access.log report this :

#*$!.xxx.xxx.xxx - - [27/Mar/2005:17:17:10 +0200] "GET / HTTP/1.1" 500 606

webstyler

3:57 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



I have try to restart machine (for other test I try to restart only apache) and now error in the log is this :

[Sun Mar 27 17:54:49 2005] [alert] [client 81.74.98.19] c:/web/.htaccess: Invalid command '//RewriteCond', perhaps mis-spelled or defined by a module not included in the server configuration

webstyler

4:14 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



now ..

in the httpd.conf I have this :

<Directory c:/Web >
Options FollowSymLinks
AllowOverride FileInfo
</Directory>

in my .htaccess i have this :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.no-ip.com.*
RewriteRule ^/$ /mydir/myfile.php [L]

When I digit http//example.no-ip.com I see c:/web root, now I don't obtain error but I'm not redirect into /mydir/myfile.php

? why?

Is rewrite only system or I can try to obtain same service for mw with virtual host?

Thks

jdMorgan

5:25 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Options not allowed here

You may need to place AllowOverride FileInfo Options before trying to use the Options directive.


<Directory c:/Web >
AllowOverride FileInfo Options
Options FollowSymLinks
</Directory>

> Invalid command '//RewriteCond'

If you want to comment-out a line in httpd.conf or .htaccess, use "#", not "//".


//RewriteCond

is incorrect, while

# RewriteCond

is interpreted only as a comment.

Jim

webstyler

7:27 am on Mar 28, 2005 (gmt 0)

10+ Year Member



ok, I have make this

But I'm not redirect :(

Caterham

11:57 am on Mar 29, 2005 (gmt 0)

10+ Year Member



You're using rules in .htaccess files, this means that the pattern of the rewrite rule (left part) will never start with a leading slash.

While

RewriteRule ^/ab$ /bc [L]
will work in the main serverConfig-Section and in virtualhosts-Containers in httpd.conf (per-server context), it will not work in .htaccess files or within <Directory> or <location>-Containers in httpd.conf (per-dir context). For per-dir context, you'll have to use
RewriteRule ^ab$ /bc [L]
, because the leading slash is already striped in this step of processing.

> But I'm not redirect :(
In this case you specified an internal redirect (= URL does not change in the location bar)
To catch your request of example.no-ip-com/ you can use:


RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)example\.no-ip\.com
RewriteRule ^$ /mydir/myfile.php [L]

webstyler

12:23 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Ok :)

with this :
RewriteCond %{HTTP_HOST} ^example\.no-ip\.com
RewriteRule ^$ /mydir/myfile.php [L]

client is correct redirect ..

thks

Now problem is refer : link is broken and image is not display, because example.no-ip.com is not really a url base .. but is example.no-ip.com/mydir/

what can I do?

thks

jdMorgan

9:01 pm on Mar 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use root-relative links.

Instead of <img src="image.gif">
use this: <img src="/path_to_image.gif"

Jim

webstyler

6:39 am on Mar 30, 2005 (gmt 0)

10+ Year Member



uhm..:(

I can modify more pages .. and there is a problem with navigation in localhost ..

Can I set document root!= only for client that arrived with [example.no-ip.com?...]

thks thks

webstyler

4:09 pm on Mar 31, 2005 (gmt 0)

10+ Year Member



or if no possible to "redirect" with [example.no-ip.com...]
On the Address
?

So I can resolve url relative/absolute problem