Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite problem

mod_rewrite apache htaccess 404

         

reza56

2:14 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Hello
I transfer my site from a cpanel host to new. My old htaccess file is :

RewriteEngine On
RewriteRule ^(.*)\.html index.php?$1

that worked fine. but in new server I get a 404 error and this on log file :

File does not exist: /usr/local/apache/htdocs/home/reza/public_html/index.php

when I want to see a page link test.html I see this error in explorer window :

The requested URL /home/topontv/public_html/index.php was not found on this server.

Can anyone help me about this problem?
thanks.

ChadSEO

3:09 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Are you able to access just [yoursite.com...] ? Does that file exist in your directory? Are you able to access any other files in that directory?

reza56

3:21 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Error Log is :

File does not exist: /usr/local/apache/htdocs/home/topontv/public_html/index.php

I mistaked it in first post

reza56

4:33 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



I can see php files like mysite.com/index.php
but other addresses have error like mysite.com/test.html

jd01

4:43 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi reza56

1st: Comment out the lines in the .htaccess file:
# RewriteEngine On
# RewriteRule ^(.*)\.html index.php?$1

Now try to open some of the files you know are there. If they open and you do not get a 404 then you know they are there.

If you do get a 404, you may need to re-upload the site.

2nd: Let's fix the syntax of your .htaccess rewrite
RewriteEngine On
RewriteRule ^(.*)\.html$ /index.php?$1

I added a $ to the left side if the rule as a hard ending, and a leading / to the right side as is required in the .htaccess file. (In the httpd.conf file the slash should be removed.)

Hope this helps.

Please, let us know how it turns out.

Justin

reza56

5:18 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



I changed my httaccess to yours but problem is exist yet. I think there is a conflict between real path and virtual path :

/home/topontv/public_html/index.php
/usr/local/apache/htdocs/home/topontv/public_html/index.php

because I see one in explorer page and one in log file.

ChadSEO

5:51 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



Mod_write and the .htaccess file doesn't care about the actual path on the server, it only looks at the path as you would see it on your site. So in the .htacces file, when you type "/index.php", this is associated with [yoursite.com...] and not translated to any specific path on the server.

reza56

6:10 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



After some try I write this

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.html$ /~topontv/index.php?$1

and problem is corrected.
thanks all