.htaccess整个网站的MOD_rewrite

时间:2011-10-20 20:49:05

标签: apache .htaccess mod-rewrite

我的网站位于www.domain / store

我想在整个网站上使用MOD_rewrite摆脱商店。

这可能与mod_rewrite ??

有关

该网站建立在Opencart上。

我尝试过以下建议: 我收到内部服务器错误所以我看了Apache错误日志,下面是错误:

[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

好的,我现在得到了答案。以下是答案!

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

1 个答案:

答案 0 :(得分:2)

很简单,使用此模式,所有内容都会为用户无形地重定向到/store/whatever。因此,您的用户输入http://example.com/some-product,Apache为用户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]