Mod Rewrite and PHP as CGI script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

your ReWriteRule is solid, but you have a problem because your redirecting using a relative url.

the browser thinks its in the directory named hasla/, so it redirects to:
domain.com/hasla/hasla.php?link=foo

but you want:
domain.com/hasla.php?link=foo

correct?

try this:

Code: Select all

RewriteEngine On
RewriteRule ^hasla/(ї^/]+)$ http://%{SERVER_NAME}/hasla.php?link=$1 їR]
this htaccess file should be in your document root
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

and you are sure the directory "hasla" does NOT exist?

what happens if you type:

http://domain.com/hasla
and
http://domain.com/hasla/

into your browser?


if the directory does not exist, i dont know why the server would throw a 403 forbidden error. i would expect a 404 error....

do you have any other rewrite rules in the htaccess, or in any other htaccess files anywhere else?
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

i dont think you should need any <files directives


what version of apache and OS is the server running?




are you using any subdomains or something like
freehosting.com/~userdir/ ?????????



first, try making the directory hasla, just make it empty

if theres no change, delete it, then:


change the htaccess to this

Code: Select all

RewriteEngine On
RewriteRule ^hasla/(&#1111;^/]+)$ http://%&#123;SERVER_NAME&#125;/hasla.php?link=$1 &#1111;L]
that should rewrite it,, but without a redirect(internal rewrite)


if still no work, change htaccess to this:

Code: Select all

RewriteEngine On
RewriteRule ^index\.php$ http://%&#123;SERVER_NAME&#125;/hasla.php?link=$1 &#1111;R]

then goto domain.com/index.php, and it should redirect to domain.com/hasla.php


tell me what the results are
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

i would talk to your host again.

what your trying to do is very simple, and they have something configured out of the ordinary and they should be able to explain what to do to thier customers.

you could also make a php file in your docroot, and do
phpinfo():

look at the file paths, see if you notice anything that could be causing this.

you could also do

print_r($_SERVER); // pay attention to the doc root and other paths


but again, i think the host should provide some documentation on this, or at least be able to provide you w/ an extrememly basic rewriterule to get you started
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I would say you are not allowed to have rewriterules :p
Post Reply