LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   .htaccess disappeared, and wont work properly (https://www.linuxquestions.org/questions/linux-newbie-8/htaccess-disappeared-and-wont-work-properly-827803/)

Helstedxd 08-22-2010 10:27 AM

.htaccess disappeared, and wont work properly
 
Hi LQ's

I have a server running Debian, and it's running PHP5, apache2, mysql and pure ftp... but when i upload .htaccess and press F5 the .htaccess file disappears... but i it still there.

the .htaccess file look like this
Code:

RewriteEngine on
RewriteRule ^php_show/([^/]+)/?$ php_show.php?id=$1

But when i create the php_show.php
with content

PHP Code:

<?php
print_r
($_GET);
?>

then go to the url http://(server ip)/php_show/test
it returns

Array ( [id] => )

bathory 08-22-2010 12:02 PM

Hi and welcome to LQ,

Your RewriteRule works here: It gives: Array ( [id] => test)
Are you sure you're using the correct .htaccess? Because you say that after uploading you cannot see it anymore, it could be that you don't have permissions to overwrite it and you're using a wrong .htaccess.

Helstedxd 08-22-2010 12:29 PM

no if i try to upload another .htaccess does my FTP client ask me if i want to overwrite the old .htaccess file, so it is there, but i can't see it

bathory 08-22-2010 12:37 PM

Yes, but are you sure that the existing .htaccess is overwritten by the one you are uploading?
Could you download it back to see if it's the correct one?

Helstedxd 08-22-2010 04:29 PM

yes i can download it, by using my browser after i have turned Deny from all off in apache2.
but i cant see it in my ftp client

bathory 08-22-2010 05:11 PM

Hi,

Leave the "Deny from all" the way it was, because otherwise .htaccess could be downloaded/viewed from others.
What ftp client are you using? Are you sure it can show "hidden" files (files that stat with a dot)?

Anyway, could you try the following rule and see if it works?
Code:

RewriteRule ^php_show/(.*)$ php_show.php?id=$1

Helstedxd 08-22-2010 11:34 PM

My FTP client is Filezilla, and that last code you send returned
Array ( [id] => )

bathory 08-23-2010 02:59 AM

So, is the .htaccess you've downloaded the same as the one you're trying to use and it's not working?
And if yes, are you sure it's not your browser cache that gives you always the same page?

Try this:
Code:

RewriteRule ^php_show/(.*)$ /php_show.php?blah=$1
and see what you get

BTW you can enable rewrite logging to find out what happens with your rule. To do so, add in httpd.conf the following
Code:

RewriteLogLevel 9
RewriteLog logs/rewrite_log


Helstedxd 08-23-2010 07:01 AM

I just found out even without a .htaccess file i can go to my php_show.php by typing

server ip/php_show

so i think that is my problem, but how to turn that access possibility off?

bathory 08-23-2010 07:34 AM

Are you sure it's not your browser's cache and you don't have other rewrite rules in httpd.conf, or the included *.conf files?

Change the rule LHS to something else (like the following) and see what you get when you visit: http://x.x.x.x/whatever/blah:
Code:

RewriteRule ^whatever/(.*)$ php_show.php?id=$1

Helstedxd 08-23-2010 09:37 AM

now i get a error 404 file

bathory 08-23-2010 12:13 PM

What does the error says? It can't find /whatever? If that's the case, most likely mod_rewrite does not work or is not loaded.
1.Run
Code:

a2enmod rewrite
to enable mod_rewrite if not already enabled.

2. Also quoting from this
Quote:

Then edit /etc/apache2/sites-available/000-default

Find the following

Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all

and change it to

Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Restart apache and see if it works.

Regadrs

Helstedxd 08-23-2010 01:53 PM

i want to say i used this tut to setup my server
http://www.howtoforge.com/perfect-se...nny-ispconfig3
can it have anything to do with it?
i have also installed ffmpeg and flvtool2
but i think i dont know how to use ISPconfig properly

bathory 08-23-2010 02:43 PM

According to the tutorial you've followed, mod_rewrite is eanbled.
So you have to check if there is a "AllowOverride all" in /etc/apache2/apache2.conf or in /etc/apache2/sites-enabled/000-default.

Or, you can put the rewrite stuff directly in /etc/apache2/sites-enabled/000-default and restart apache to see if .htaccess is the problem

Helstedxd 08-23-2010 03:04 PM

etc/apache2/sites-available/000-default <- is empty on my server, but i think it's ISPconfig that is doing it, so i think i will formate my server and not install ISPconfig :D


All times are GMT -5. The time now is 01:06 PM.