2012-11-27 42 views
1

我最近使用prestashop建了一家商店,prestashop的生产安装位于名为/ prestashop的服务器的子目录中。我想要做的是让你不必去http://mydomain.com/prestashop来查看网站,而只是http://mydomain.com将/ prestashop /部分网址隐藏

有两种方法我想到目前为止,我可以移动prestashop的前端控制器索引文件的根,类似于在wordpress中做的,尽管我不确定这是否是一个可行的选择,因为我没有足够的经验来解决它。这里是index.php文件对所有感兴趣的那些代码:

require(dirname(__FILE__).'/config/config.inc.php'); 
Dispatcher::getInstance()->dispatch(); 

第二个选择是使用Apache的mod_rewrite模块,使您有类似

RewriteEngine on 
RewriteRule ^/(.*)$ /prestashop/$1 

但我打开htaccess文件已经存在,这代码是存在的,所以我不知道如果这可以被编辑不能:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www.mydomain.com$ 
RewriteRule . - [E=REWRITEBASE:/prestashop/] 
RewriteRule ^api/?(.*)$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L] 

我会继续玩耍,并试图找出自己,但你的任何帮助球员将是五个非常感谢。提前致谢。

+0

如果你用'重写规则重定向^ /(。 *)$/prestashop/$ 1'或任何类似规则,您将无法访问根目录。那是你要的吗? –

+0

是的,我只是希望用户直接去mydomain.com/prestashop –

回答

1

我不知道是否会的Prestashop正确地计算出路径,而是试图改变你的index.php文件:

require(dirname(__FILE__).'/prestashop/config/config.inc.php'); 
Dispatcher::getInstance()->dispatch(); 

我会避免使用的.htaccess这个如果可能的话,因为它只是更多通过对每个请求进行更多重写来产生开销。

基本上所有这些都是修改前端控制器代码,以便在配置的正确目录(/ prestashop)中查找。它不应该是一个问题。

编辑:您还需要将.htaccess文件从/prestashop/.htaccess移动到/.htaccess,以便重写URL仍然有效。

+0

当我这样做时,它仍然重定向到/ prestashop /,也许这是由于.htaccess文件中的现有代码? –

+1

它可能是Prestashop中的PHP代码。有配置文件或管理员定义站点URL的设置吗?如果是这样,请尝试将其更改为yourdomain.com而不是yourdomain.com/prestashop – drew010

+0

有一个设置有“base uri”,将其更改为/,现在我的所有css和图像都已损坏,但无论如何您都可以解决它! :D谢谢你 –

1

http://www.prestashop.com/forums/topic/18393-solved-move-prestashop-from-subfolder-to-root/

指令/从michaeld暗示我想通了,它的作品!

此外,如果您使用PrestaShop媒体服务器,请添加重写。

下面是完整的.htaccess为我的作品:

# Copy and paste the following code into the .htaccess file 
# in the public_html folder of your hosting account 
# make the changes to the file according to the instructions. 

# Do not change this line - RewriteEngine on 
RewriteEngine on 

# Change yourdomain.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$ 

# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/subfolder/ 

# Don't change this line. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteRule ^(.*)$ /subfolder/$1 

# Change yourdomain.com to be your main domain again. 
# Change 'subfolder' to be the folder you will use for your main domain 
# followed by/then the main file for your site, index.php, index.html, etc. 
RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$ 
RewriteRule ^(/)?$ subfolder/index.php [L] 


# For PrestaShop Media server #1 
# Change mediaserver1.yourdomain.com to be your media server subdomain 
# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteCond %{HTTP_HOST} ^mediaserver1.yourdomain.com$ 
RewriteCond %{REQUEST_URI} !^/subfolder/.*$ 
RewriteRule ^(.*)$ /subfolder/$1 

# For PrestaShop Media server #2 
# Change mediaserver2.yourdomain.com to be your media server subdomain 
# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteCond %{HTTP_HOST} ^mediaserver2.yourdomain.com$ 
RewriteCond %{REQUEST_URI} !^/subfolder/.*$ 
RewriteRule ^(.*)$ /subfolder/$1 


# For PrestaShop Media server #3 
# Change mediaserver3.yourdomain.com to be your media server subdomain 
# Change 'subfolder' to be the folder you will use for your main domain. 
RewriteCond %{HTTP_HOST} ^mediaserver3.yourdomain.com$ 
RewriteCond %{REQUEST_URI} !^/subfolder/.*$ 
RewriteRule ^(.*)$ /subfolder/$1 

PS:请确保您在的Prestashop BO组物理URL为 “/”