Forum Moderators: phranque

Message Too Old, No Replies

Reply to: Mod rewrite and Godaddy

mod_rewrite fix for godaddy shared hosting

         

bjtylerx

3:51 pm on Dec 16, 2007 (gmt 0)

10+ Year Member



The original message I found was here (but it was closed for more replies): [webmasterworld.com...]

I just wanted to throw in my 2 cents because I found a fix for my mod_rewrite godaddy problem. All I had to do was turn off multiviews and all my old mod_rewrite stuff worked again. Turn it off with this line in your .htaccess file:

Options -MultiViews

[edited by: jdMorgan at 4:03 pm (utc) on Dec. 16, 2007]

jdMorgan

4:22 pm on Dec 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Options -MultiViews can be combined with Options +FollowSymLinks, as shown in the code posted in the thread cited above.

Jim

Wild Striker

1:09 pm on Dec 18, 2007 (gmt 0)

10+ Year Member



I have a problem with mod rewrite .htaccess on GoDaddy hosting. Can smb help me?

This is my htaccess, which works, BUT not on GoDaddy *(

AddDefaultCharset utf-8
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^main.php(.*)$ $0 [L]
RewriteRule ^more.html$ $0 [L]

RewriteRule ^images/(.*)$ $0 [L]
RewriteRule ^uimg/(.*)$ $0 [L]
RewriteRule ^style.css$ $0 [L]
RewriteRule ^favicon.ico$ $0 [L]

RewriteRule ^index.php(.*)$ $0 [L]
RewriteRule ^(.*)$ index.php [L]

How to make it work?

jdMorgan

7:32 pm on Dec 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Those rules are ill-formed, and I'm surprised they work anywhere -- $0 is undefined in mod_rewrite, to start with.

Because of this, we'll need some more information about what each rule is intended to do -- A good start would be to add comment lines above each rule to document for us and for yourself the intent of each rule.

Jim

Wild Striker

12:16 pm on Dec 19, 2007 (gmt 0)

10+ Year Member



First of all, it's not mine and I'm not good at this.
As I know...$0 - first expression , $1 - second exp.

## The main idea is to restrict (in url) all files from root directory, and allow only this:

RewriteRule ^main.php(.*)$ $0 [L]
RewriteRule ^more.html$ $0 [L]

RewriteRule ^images/(.*)$ $0 [L]
RewriteRule ^uimg/(.*)$ $0 [L]
RewriteRule ^style.css$ $0 [L]
RewriteRule ^favicon.ico$ $0 [L]

RewriteRule ^index.php(.*)$ $0 [L]
RewriteRule ^(.*)$ index.php [L]


p.s. [this .htaccess works normally on my blog] -- it's not on GoDaddy's hosting.

[edited by: Wild_Striker at 12:20 pm (utc) on Dec. 19, 2007]

[edited by: jdMorgan at 12:59 am (utc) on Dec. 20, 2007]
[edit reason] Removed specifics per TOS. [/edit]

jdMorgan

1:01 am on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> As I know...$0 - first expression , $1 - second exp.

Mod_rewrite defines only $1 through $9, for the first through the ninth back-reference only. $0 is undefined. See Apache mod_rewrite documentation.

Jim

Wild Striker

2:43 pm on Dec 20, 2007 (gmt 0)

10+ Year Member



strange...'cause it's working on other hostings. But on godaddy NOT*(

anyway, how should it be right? i don't understand *(

like I said, the main idea is to restrict all, and allow only:
main.php , more.html, style.css, favicon.ico

and all in derictories: images/ and uimg/

And there can be added befor and after index.php

Ser

jdMorgan

6:23 pm on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In accordance with our forum charter [webmasterworld.com], our purpose here is to help you understand, not to serve as a help desk or a free code-writing service. Because this code is malformed, we cannot guess at its purpose or its function. So I'm afraid it will be up to you to do the research to find out what the purpose of each line of code is, and how to fix it. We will be more than happy to answer specific questions about mod_rewrite.

By testing the code using the URL-paths matched in each rule on the working server, you may be able to discern how it works. It is possible that many of the rewrites to $0 are actually intended to exclude those URL-paths from being rewritten by the last rule. But again it is hard to tell, since $0 is undefined by the mod_rewrite documentation, and --as your experience shows-- may give different results on different OS and Apache version installations.

Jim