You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Drew Tomlinson <dr...@mykitchentable.net> on 2010/01/21 00:24:03 UTC

[users@httpd] ModRewrite Help

I'm trying to use mod_rewrite to rewrite the URL displayed in the 
browser address bar to the "www." form as described here:

http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html#canonicalhost

This particular site is a ZenCart installation that is hosted.  Thus I 
have to use .htaccess files to make modifications.

I am already using a ZenCart module that rewrites URLs from a form such as:

http://alchemistswarehouse.com/store/index.php?main_page=product_info&cPath=39&products_id=7296

to a more SEO friendly form like:

http://alchemistswarehouse.com/store/digital-products/card-tricks-vol-1

I have these rules in my .htaccess file to accomplish the SEO friendly 
rewrite:

#### BOF SSU
Options +FollowSymLinks -MultiViews
RewriteEngine On

# Make sure to change "zencart" to the subfolder you install ZC.
RewriteBase /store/

# Deny access from .htaccess
RewriteRule ^\.htaccess$ - [F]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 [E=VAR1:$1,QSA,L]
#### EOF SSU

To always rewrite the URL to http://www.alchemistswarehouse.com/*, I've 
created this code:

RewriteCond %{HTTP_HOST}   !^www\.alchemistswarehouse\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.alchemistswarehouse.com/$1 [R]

I have tried putting this code in my .htaccess file in different places 
but it doesn't seem to have any effect.  I've even removed the "L" flag 
from the SSU RewriteRule above but still no luck.

What am I missing?

Thanks,

Drew

-- 
Be a Great Magician!
Visit The Alchemist's Warehouse

http://www.alchemistswarehouse.com



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] ModRewrite Help

Posted by Eric Covener <co...@gmail.com>.
On Wed, Jan 20, 2010 at 7:57 PM, Drew Tomlinson <dr...@mykitchentable.net> wrote:
> Eric Covener wrote:
>>
>> On Wed, Jan 20, 2010 at 6:24 PM, Drew Tomlinson <dr...@mykitchentable.net>
>> wrote:
>>
>>>
>>> RewriteRule ^/(.*)         http://www.alchemistswarehouse.com/$1 [R]
>>>
>>> I have tried putting this code in my .htaccess file in different places
>>> but
>>> it doesn't seem to have any effect.  I've even removed the "L" flag from
>>> the
>>>
>>
>>
>> This rule is a no-op in htaccess.  In htaccess, the string you're
>> comparing to never has a leading slash -- the entire rewritebase is
>> stripped off  ("/" is stripped off in the DocumentRoot, for example)
>>
>
> Thanks for your reply. So is there any way to do what I want with .htaccess?

Yes, just use ^(.*) without the /, and make sure your htaccess is
being read at all (AllowOverride)


>
> Cheers,
>
> Drew
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] ModRewrite Help

Posted by Drew Tomlinson <dr...@mykitchentable.net>.
Eric Covener wrote:
> On Wed, Jan 20, 2010 at 6:24 PM, Drew Tomlinson <dr...@mykitchentable.net> wrote:
>   
>> RewriteRule ^/(.*)         http://www.alchemistswarehouse.com/$1 [R]
>>
>> I have tried putting this code in my .htaccess file in different places but
>> it doesn't seem to have any effect.  I've even removed the "L" flag from the
>>     
>
>
> This rule is a no-op in htaccess.  In htaccess, the string you're
> comparing to never has a leading slash -- the entire rewritebase is
> stripped off  ("/" is stripped off in the DocumentRoot, for example)
>   
Thanks for your reply. So is there any way to do what I want with .htaccess?

Cheers,

Drew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] ModRewrite Help

Posted by Eric Covener <co...@gmail.com>.
On Wed, Jan 20, 2010 at 6:24 PM, Drew Tomlinson <dr...@mykitchentable.net> wrote:
> RewriteRule ^/(.*)         http://www.alchemistswarehouse.com/$1 [R]
>
> I have tried putting this code in my .htaccess file in different places but
> it doesn't seem to have any effect.  I've even removed the "L" flag from the


This rule is a no-op in htaccess.  In htaccess, the string you're
comparing to never has a leading slash -- the entire rewritebase is
stripped off  ("/" is stripped off in the DocumentRoot, for example)

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org