L
L
lilwings2019-12-21 12:47:28
Yii
lilwings, 2019-12-21 12:47:28

how can i remove web from url in yii2 xampp?

The web folder contains this .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

At the root of the application:
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
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

Here's what you get if you remove the web from the url:
5dfde9bbdd084810554846.png
PS: Everything works with the web in the url, how to make the correct redirection to the web folder?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2019-12-21
@lilwings

At the root of the application, in .htaccess

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine on
</IfModule>

<IfModule mod_rewrite.c>
   RewriteCond %{REQUEST_URI} ^/.*
   RewriteRule ^(.*)$ web/$1 [L]

   RewriteCond %{REQUEST_URI} !^/web/
   RewriteCond %{REQUEST_FILENAME} !-f [OR]
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^.*$ web/index.php

</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question