homepage Welcome to WebmasterWorld Guest from 54.166.105.24
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess issue
htaccess in godaddy subfolder
prithviphp



 
Msg#: 4524248 posted 12:57 am on Dec 2, 2012 (gmt 0)

Hi Guys,

I am very new to htaccess stuffs and so seeking your kind co-operation.

The site is hosted in a godaddy subfolder.

The site is http://example.com/

In godaddy http://www.abc.com/example refers to http://example.com/

Now the files are located in /html/example/ where html is the root directory.

The problem is that any inner page redirects to 404 page.I guess it's a directory issue but I don't know where to change.The htaccess file is like below.

RewriteEngine On


RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{REQUEST_URI} /print.*

RewriteRule ^print/([^.]+)$ print_template.php?domain=$1 [QSA,L]


RewriteCond %{REQUEST_URI} !/blog.*
RewriteCond %{REQUEST_URI} !/admin.*

RewriteRule ^browse/(.*)$ index.php?pars=browse/$1 [QSA,L]

RewriteRule ^([^.]+)$ index.php?pars=$1 [QSA,L]



Please suggest.

Thanks,
Raj

[edited by: tedster at 3:24 am (utc) on Dec 4, 2012]
[edit reason] switch to example.com [/edit]

 

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4524248 posted 1:10 am on Dec 2, 2012 (gmt 0)

What do you mean by "redirects to 404 page"? What URL do you request? What does the address bar say when the error page is displayed?

Please use example.com in posts in this forum as it prevents the URL auto-linking function from activating. There may still be time for you to re-edit your post.

The www/non-www code is non-optimum.

The preceding condition of the second ruleset is not needed. The pattern to match is already defined in the rule.

Trailing uncaptured .* is always redundant on any unanchored pattern and can be removed.

The rule target probably needs to include the target folder name not just the index.php filename.

prithviphp



 
Msg#: 4524248 posted 2:20 am on Dec 2, 2012 (gmt 0)

Hi

Thanks for your reply.It redirects to a 404 page when I browse any page.It says "The requested URL /shortbrands/index.php was not found on this server."The address bar says

example.com/pagename

Sorry I didn't understand the following line

"The preceding condition of the second ruleset is not needed. The pattern to match is already defined in the rule.

Trailing uncaptured .* is always redundant on any unanchored pattern and can be removed."

Sgt_Kickaxe

WebmasterWorld Senior Member sgt_kickaxe us a WebmasterWorld Top Contributor of All Time



 
Msg#: 4524248 posted 1:27 am on Dec 14, 2012 (gmt 0)

This sounds like a godaddy shared environment specific issue where the site is not declared as the *main* site on a hosting plan.

Possible solution:
add the following immediately after the opening RewriteEngine on

RewriteBase /

I know that's default behavior but when you have multiple sites in one account on Godaddy it helps the server find the right index.php file within that folder instead of attemting to load the index.php from the *main* folder.

prithviphp



 
Msg#: 4524248 posted 3:31 am on Dec 14, 2012 (gmt 0)

Hi

Thanks for your reply.Now i got a new issue.

The url for subdomain is http ://m.domain.co.uk which redirects from http ://www.domain.co.uk/m

Now the main site's index file is under

/m/webstores/ecommerce/

In that index file the link for the product is

shopping-cart/293/test where 293 is the product id and test is product name.

Now the htaccess code is

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^(www\.)?domain.co.uk/webstores/ecommerce/(.*)
RewriteRule (.*) http://m.domain.co.uk/%1 [R=301,L]
RewriteRule ^(\d+)/([^/]+)/?$ /shopping-cart/index.php?uiid=$1&title=$2 [L]


The htaccess file is located under

/m/webstores/ecommerce/

The above code is detecting the subdomain correctly ie [m.domain.co.uk...] but not the product url.

Please suggest me what's the wrong I am doing.

Best, Raj

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4524248 posted 8:07 am on Dec 14, 2012 (gmt 0)

First, to reiterate:
Please use example.com in posts in this forum

Eventually people get tired and stop saying "please". Or, conversely, people figure out why they have to put gratuitous spaces into lines like
The url for subdomain is http ://m.domain.co.uk which redirects from http ://www.domain.co.uk/m

Does it redirect-- the user's address bar changes-- or does the user type in "m.example.co/" and get served content that lives at "www.example.co/m/" ? Or the other way around? Or neither?

You say "the above code". But you've got two separate rules and it's important to understand they have nothing to do with each other. In particular, the Condition only goes with the first Rule, whether that rule executes or not.

Rule 1 is a redirect with accompanying condition:
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^(www\.)?example.co.uk/webstores/ecommerce/(.*)
RewriteRule (.*) http:/ /m.example.co.uk/%1 [R=301,L]

Yes, OK, so sometimes even "example.co" isn't enough.

Is this rule supposed to be about the host or about the body or the URI? It's generally safer to deal with one thing at a time, especially when you're not sure what you are doing. If the Rule requires you to look at the host, make that a Condition by itself. And then dump the REQUEST_URI part and shift it to the body of the Rule. You don't need to say the same thing twice. Here what you've really got is a redirect from

/webstores/ecommerce/.*
to
http:/ /m.example.co.uk/www.

-- the "www." is the first capture in the Condition-- which is clearly gibberish, so you must have left something out. Although both the Rule and the Condition capture the request, neither capture shows up in the target.

Rule 2 is a Rewrite without conditions:
RewriteRule ^(\d+)/([^/]+)/?$ /shopping-cart/index.php?uiid=$1&title=$2 [L]

This rule takes input in the form "www.example.com/one-or-more-numbers/more-stuff with optional final slash" and serves content from www.example.com/index.php?uiid={the numbers from the request}&title={the rest of the request}. Is that what it's meant to do? Is this the part that isn't executing?

While you're working on it, do something about the optional final slash. You've created a duplicate URI, which is never good. It would be fine in a redirect, because the user ends up in a different place anyway. But never never in a rewrite.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4524248 posted 9:27 am on Dec 14, 2012 (gmt 0)


RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^(www\.)?example.co.uk/webstores/ecommerce/(.*)
RewriteRule (.*) http:/ /m.example.co.uk/%1 [R=301,L]


you probably want something more like this:

RewriteRule ^webstores/ecommerce/(.*)$ http://m.example.co.uk/$1 [R=301,L]

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4524248 posted 9:42 am on Dec 14, 2012 (gmt 0)


RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^(www\.)?example.co.uk/webstores/ecommerce/(.*)
RewriteRule (.*) http:/ /m.example.co.uk/%1 [R=301,L]

actually the correct solution depends on whether you intended the %1 to be a $1 or a %2.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved