Solved

How do i rewrite a folder to not show in .htaccess page?

Posted on 2009-07-06
17
326 Views
Last Modified: 2013-12-25
Greetings i know this should be easy, but i can't seem to get the correct syntax to make this work.... We are using a Magento site.

The site is located in a folder called http://www.mysite.com/magento/

How can i take away the folder in the url  /magento/ to only show http://www.mysite.com

i have messed around with the .htacess page on the root folder (public_html) and got it to work if you type in http://www.mysite.com. It shows the correct info under the magento folder.

But what i want is to type in  http://www.mysite.com/magento/work-clothes/
and have it show  http://www.mysite.com/work-clothes/ in the address bar. Any Help is greatly appreciated.
##### THIS I S ON THE ROOT LEVEL OF SITE
 

RewriteEngine On

RewriteRule ^(.*)$ magento/$1 [L]

RewriteCond %{REQUEST_URI} ^/admin

RewriteRule ^(.*)$ magento/$1 [L]

Open in new window

0
Comment
Question by:Fullsource
  • 7
  • 6
  • 4
17 Comments
 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
RewriteRule ^(.*)$ /magento/$1 [L]

try a slash in front of magento
0
 

Author Comment

by:Fullsource
Comment Utility
so would the code then be:

RewriteEngine On
RewriteRule ^(.*)$ /magento/$1 [L]
RewriteCond %{REQUEST_URI} ^/


because that doesn't seem to work. What i need is the RewriteCond  to be different i think. Bassically i need it rewrite the folder to not show the /magento/ part.

0
 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
I see no need for rewritecond for what you're trying to do.
0
 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
I tried it on one of my servers and it works just fine.

0
 

Author Comment

by:Fullsource
Comment Utility

Below this paragraph is the code i got from he server help page. I am trying to use their script to make it happen. but the script has the <admin_path> in the RewriteCond. Anyway. are you saying that i don't need to put that line of code in there or what? Can you please just write exactly  what i need to put in there to work. because i tried this

RewriteEngine On
RewriteRule ^(.*)$ /magento/$1 [L]

and it doesn't work either. Thanks for any help again.


---------------------------------------------------
SEVER HELP CODE HERE
--------------------------------------------------


Place this code in your .htaccess on your root folder where "magento" is the directory of the magento you've installed in:


RewriteEngine On

RewriteRule ^(.*)$ magento/$1 [L]

RewriteCond %{REQUEST_URI} ^/<admin_path>

RewriteRule ^(.*)$ magento/$1 [L]

Note : <admin_path> should be replaced. For ex. admin







0
 

Author Comment

by:Fullsource
Comment Utility
maybe the cache or something i s keeping it? Not sure why it won't work for this magento site.
0
 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
My additional thought is that the .htaccess file is not being processed at all.  Perhaps a .htaccess permissions issue?
0
 

Author Comment

by:Fullsource
Comment Utility
not sure. becuase when i make a mistake on the .htacess page it disrupts the process... basically throws an error.

Sorry i  am sure you are right about the code. because that was my initial code i tried too. but for some crazy reason it doesn't seem to want to work. like i said before the rewrite works if i type in

http://www.mysite.com/
(shows the index.php page for the magento folder)

but not
http://www.mysite.com/magento/index.php
(want to show as http://www.mysite.com/)

Frustrating I know.


0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
so, if they type magento, you want it to remove the magento for them?

I was only trying:  
http://www.mysite.com/
(shows the index.php page for the magento folder)

I was not trying
http://www.mysite.com/magento/index.php
(want to show as http://www.mysite.com/)

The additional rewrite rule gives the browser a redirect.. order is important.
note its possible you don't need the leanding / .... ^magento/(.*)$
try it both ways.



RewriteEngine On

RewriteRule ^/magento/(.*)$ /$1 [RL]

RewriteRule ^(.*)$ /magento/$1 [L]

Open in new window

0
 

Author Comment

by:Fullsource
Comment Utility
k. i'll give er a try. thanks
0
 

Author Comment

by:Fullsource
Comment Utility
I tried both ways and  no luck... here is the entire htacess page. maybe you can see somehting i don't that may be overriding it? I hope so, cause this thing is not working like it should. I increased the point value too. cause apparently this one is harder than expected.
############################################

## uncomment these lines for CGI mode

## make sure to specify the correct cgi php binary file name

## it might be /cgi-bin/php-cgi
 

#    Action php5-cgi /cgi-bin/php5-cgi

#    AddHandler php5-cgi .php
 
 
 

############################################
 
 

RewriteEngine On

RewriteCond %{HTTP_HOST} ^ralzaider\.com [NC]

RewriteRule (.*) http://www.ralzaider.com/$1 [R=301,L]
 
 
 

############################################
 
 

RewriteEngine On

RewriteRule ^magento/(.*)$ /$1 [RL]

RewriteRule ^(.*)$ magento/$1 [L]
 
 

############################################

## GoDaddy specific options
 

#   Options -MultiViews
 

## you might also need to add this line to php.ini

##     cgi.fix_pathinfo = 1

## if it still doesn't work, rename php.ini to php5.ini
 

############################################

## this line is specific for 1and1 hosting
 

    #AddType x-mapp-php5 .php

    #AddHandler x-mapp-php5 .php
 

############################################

## default index file
 

    DirectoryIndex index.php
 

<IfModule mod_php5.c>
 

############################################

## adjust memory limit
 

    php_value memory_limit 64M

    php_value max_execution_time 18000
 

############################################

## disable magic quotes for php request vars
 

    php_flag magic_quotes_gpc off
 

############################################

## disable automatic session start

## before autoload was initialized
 

    php_flag session.auto_start off
 

############################################

## enable resulting html compression
 

    #php_flag zlib.output_compression on
 

###########################################

# disable user agent verification to not break multiple image upload
 

    php_flag suhosin.session.cryptua off
 

###########################################

# turn off compatibility with PHP4 when dealing with objects
 

    php_flag zend.ze1_compatibility_mode Off
 

</IfModule>
 

<IfModule mod_security.c>

###########################################

# disable POST processing to not break multiple image upload
 

    SecFilterEngine Off

    SecFilterScanPOST Off

</IfModule>
 

<IfModule mod_deflate.c>
 

############################################

## enable apache served files compression

## http://developer.yahoo.com/performance/rules.html#gzip
 

    # Insert filter on all content

    ###SetOutputFilter DEFLATE

    # Insert filter on selected content types only

    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
 

    # Netscape 4.x has some problems...

    #BrowserMatch ^Mozilla/4 gzip-only-text/html
 

    # Netscape 4.06-4.08 have some more problems

    #BrowserMatch ^Mozilla/4\.0[678] no-gzip
 

    # MSIE masquerades as Netscape, but it is fine

    #BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
 

    # Don't compress images

    #SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
 

    # Make sure proxies don't deliver the wrong content

    #Header append Vary User-Agent env=!dont-vary
 

</IfModule>
 

<IfModule mod_ssl.c>
 

############################################

## make HTTPS env vars available for CGI mode
 

    SSLOptions StdEnvVars
 

</IfModule>
 

<IfModule mod_rewrite.c>
 

############################################

## enable rewrites
 

    Options +FollowSymLinks

    RewriteEngine on
 

############################################

## you can put here your magento root folder

## path relative to web root
 

   RewriteBase /magento/
 

############################################

## workaround for HTTP authorization

## in CGI environment
 

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
 

############################################

## always send 404 on missing files in these folders
 

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
 

############################################

## never rewrite for existing files, directories and links
 

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-l
 

############################################

## rewrite everything else to index.php
 

    RewriteRule .* index.php [L]
 

</IfModule>
 
 

############################################

## Prevent character encoding issues from server overrides

## If you still have problems, use the second line instead
 

    AddDefaultCharset Off

    #AddDefaultCharset UTF-8
 

<IfModule mod_expires.c>
 

############################################

## Add default Expires header

## http://developer.yahoo.com/performance/rules.html#expires
 

    ExpiresDefault "access plus 1 year"
 

</IfModule>
 

############################################

## By default allow all access
 

    Order allow,deny

    Allow from all
 

############################################

## If running in cluster environment, uncomment this

## http://developer.yahoo.com/performance/rules.html#etags
 

    #FileETag none

Open in new window

0
 
LVL 12

Expert Comment

by:kevin_u
Comment Utility
remove the second RewriteEngine On

Lets change the second rule to this:
RewriteRule ^magento/(.*)$ http://www.ralzaider.com/$1 [R=301,L]

You should combine lines 11 thru 28 to the following snippet
############################################

 

 

RewriteEngine On

RewriteCond %{HTTP_HOST} ^ralzaider\.com [NC]

RewriteRule (.*) http://www.ralzaider.com/$1 [R=301,L]

RewriteRule ^magento/(.*)$ http://www.ralzaider.com/$1 [R=301,L]

RewriteRule ^(.*)$ magento/$1 [L]

Open in new window

0
 
LVL 29

Expert Comment

by:fibo
Comment Utility
Hmm..
Can I make a stupid suggestion: since all your site start from the /magento/ directory, have you checked if you cannot change something either on your DNS or on the server domain handler so that your site is directed right into /magento/?

It would be simpler, 'cause presently there are lots of errors: top links point to http://localhost/..., link to home points in fact to http://(space)www.ralzaider.com/magento/ etc

If your hosting has subdomains or multidomain, this tuning up should not be a problem
0
 

Author Comment

by:Fullsource
Comment Utility
Dude. soooooo close. I've got it working the way i need it, but now i need the write an exception for the admin folder. FYI in Magento sites, you need to change the base url in the CMS's web Configuration to have this all work. So for all the points.... please can you help me write an .htaccess script the stops it from rewriting the /magento/ only when the url looks like magento/admin/.....
Thanks so far for everything!
 
0
 
LVL 29

Accepted Solution

by:
fibo earned 500 total points
Comment Utility
There are 2 separate issues to solve and you need to be sure on which one you are working at a stage.

Issue 1:
- get all rewrites or equivalent to work for non admin pages
- suggested solutions: either
a -  don't use htaccess for that, have the site/dns point to the right directory
b - stay with your current config, but use the standard rewrite rules in htaccess, adjusting the rewritebase line in htaccess (uncomment it)

Issue 2:
- manage the admin issue (I have for now decided in my config to stay with the standard /admin/)
- this involves both indicating to Magento the name of the path to admin, and finding ways so thatthe right things happen,
- I suggest you do as explained in http://www.magentocommerce.com/boards/viewthread/34357/ (first read the complete thread)
0
 
LVL 29

Expert Comment

by:fibo
Comment Utility
In fact it seems that you cross-potsed to
http://www.experts-exchange.com/Q_24554405.html where you have good suggestions as well
0
 
LVL 29

Expert Comment

by:fibo
Comment Utility
Glad it helped. Thx for the points and grade.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now