2013-11-21 12:49 阅读 54


My problem is i bought a shity hosting and now i can not set my own config. I need to do it by .htaccess file. Here is what i manage to do:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_URI} !^/Project/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /Project/web/$1
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ Project/web/app.php [L]

I know that this will not work with some website software like mine. and I also need to modify the $base_url, $live_site or other configuration settings in those to finish the process.

To make it all clear with this settings when i enter my domain i start from subdirectory i choose. but when i try to go to another page its return 404 error.

I have an idea how to make it work, its need to redirect also routing so for example www.domain.com/page need to be redirected to www.domain.com/Project/web/page if anyone know how to do it ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dtvpe4837413 dtvpe4837413 2013-11-21 13:02

    I installed symfony on a shared hosting service one time.

    That's what I had to do to make Symfony work :

    in the public directory there is the structure of the project :


    In /.htaccess I wrote :

    SetEnv PHP_VER 5_3
    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /web
       RewriteCond %{REQUEST_URI} \.(css|gif|ico|jpg|js|png|swf|txt|pdf|doc|docx|mp3|svg)$
       RewriteRule ^(.*)$ $1 [QSA,L]
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ web/app.php/$1 [QSA,L]

    in /web/.htaccess I wrote :

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ app.php [QSA,L]

    That's all...

    点赞 评论 复制链接分享
  • douraoyw194498 douraoyw194498 2013-11-21 12:54

    Maybe the PHP header function?

    <?php header("Location: http://www.example.com/"); exit; ?>

    PHP: header

    点赞 评论 复制链接分享