htaccess/url rewrite with Silex, XAMPP, and multifolder structure

285 Views Asked by At

I've tried searching multiple previous threads on setting up url rewrite correctly for a Silex application on XAMPP, but still can't figure this issue out. Here is what I am trying to accomplish.

I am using XAMPP and here is the structure of my htdocs folder:

    - xampp 
        - htdocs
            - app1
            - app2
            - app3 <silex application>
                .htaccess file (outside of web folder)
                - web
                    index.php file

I can currently do http://localhost:50000/msk/web/cte. My question is how do I get rid of "web" from this (i.e. http://localhost:50000/msk/cte)

I feel like I'm missing something minor, but I can't figure it out.

    <IfModule mod_rewrite.c>
       Options -MultiViews

       RewriteEngine On
       RewriteBase /msk/web/
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^ index.php [QSA,L]
    </IfModule>

LoadModule rewrite_module modules/mod_rewrite.so is un-commented in my config. I am not using virtual hosts either.

Thanks

3

There are 3 best solutions below

0
Ashu On

You can try :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /msk/web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

RewriteRule ^cte/url-word$ cte/redirect-page [L]

</IfModule>
0
Saeed.Gh On

use the following .htaccess in /msk directory:

Options +FollowSymLinks
IndexIgnore */*

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(web)
# ------- browser looks for them on base url -------- ex: /images/logo.png
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
</IfModule>

and use this .htaccess in your /msk/web directory

<IfModule mod_rewrite.c>
RewriteEngine On 

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php
</IfModule>
0
Saclt7 On

Try this one

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>