1
votes

Now I'm working on localhost:8080/basic/web. What I want to do it try to rewrite the url into localhost:8080/basic only. here is my .htaccess file

RewriteEngine on
# Change yourdomain.com to be your primary domain.

RewriteCond %{HTTP_HOST} ^(www.)?localhost:8080$

RewriteCond %{REQUEST_URI} !^/basic/web/

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

RewriteRule ^(.*)$ /basic/web/$1

RewriteCond %{HTTP_HOST} ^(www.)?localhost:8080$ 
RewriteRule ^(/)?$ basic/web/index.php [L]

Please help!!!

1
you are trying to solve the wrong problem, do you want to do this because you are on a shared server? - Mihai P.
any luck have you resolved the problem .? - Developer

1 Answers

3
votes

I suggest three way:
1. Config Virtual host direct to web folder

<VirtualHost *:8080>
    DocumentRoot ".../basic/web"
    ServerName localhost
</VirtualHost>

2. Create a htacess file in /basic folder

RewriteEngine On
RewriteRule ^(.*)$ web/$1 [L]

3. Move all web folder to webroot like this : https://github.com/kartik-v/yii2-app-practical-b