1

I have a site that is under www.domain/store

I want to get rid of store using MOD_rewrite for the entire site.

Is this possible to do with mod_rewrite??

The site is built on Opencart.

I've tried what was suggested below: I'm getting internal server error so I've looked at Apache error log and below are the errors:

[Sun Oct 23 03:02:09 2011] [error] [client 120.144.194.243] File does not exist: /home/favstayc/public_html/404.shtml [Sun Oct 23 03:02:09 2011] [error] [client 120.144.194.243] File does not exist: /home/favstayc/public_html/favicon.ico [Sun Oct 23 03:02:09 2011] [error] [client 120.144.194.243] client denied by server configuration: /home/favstayc/public_html/error_log [Sun Oct 23 03:02:09 2011] [error] [client 120.144.194.243] client denied by server configuration: /home/favstayc/public_html/.htaccess 

OK I got my answer now. Below is the answer!

Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} !(.*)store RewriteRule ^(.*)$ store/$1 [L] 

1 Answer 1

2

Quite simply, using this pattern everything redirects to /store/whatever invisibly for the user. So your user enters http://example.com/some-product, and Apache serves the user http://example.com/store/some-product.

RewriteEngine On #RewriteCond %{REQUEST_URI} !^store.*$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /store$1 [L,QSA] 
Sign up to request clarification or add additional context in comments.

5 Comments

I don't want to have store appearing on the url. Is it possible?
That's exactly what this rule does. Unless you add a [R], flag it will not redirect the user's browser.
@hybmg58 Check your Apache error_log to see what the error is. Also see addition of RewriteCond above.
OK I'm getting this error now: This webpage has a redirect loop
@hybmg58 See addition, which checks if the requested item is a real file (i.e., it exists in the store directory). If it does, the rewrite doesn't take place so you don't get a loop.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.