My index.php is in public folder and in my .htaccess file I say that rewrite base is the public directory. But when I open the cms.test, it gives me cms folders.. for the use index php, still I need to go public folder..
here is my .htaccess file
Options -MultiViews
RewriteEngine On
RewriteBase /var/www/cms/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA]
How do I fix this ?
Set your public folder to be the root directory
Options -MultiViews
RewriteEngine On
RewriteBase /var/www/cms/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA]
Set your public folder to be the root directory
Related
Sorry for the inconvenience, I am new to PHP and I am trying to redirect with the .htaccess file to the public folder and inside that folder to the index.php file. What am I doing wrong? please I look forward to your support
.htaccess
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /Proyecto_prueba/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
I keep seeing the root with its two folders public and the app
I have a website like www.abc.com/service/page.php?ids=social. I redirected site to www.abc.com/service/social. But i need to avoid this folder from url.Ex:www.abc.com/social.
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /service/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+|)/?$ page.php?ids=$1
Simply exclude "service" from the regex match:
RewriteRule ^service/([a-zA-Z0-9]+|)/?$ page.php?ids=$1
Place this code in site root .htaccess (i.e. parent directory of /service/):
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^service/ service%{REQUEST_URI} [L,NC]
I'm doing a simple MVC from scratch and my project is in /var/www/test_mvc where I have two subfolders: app and public. the public subfolder is where the users will access.
So, in my .htaccess I have this code:
Options -MultiViews
RewriteEngine On
RewriteBase /test_mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
In the constructor of the Index controller I print the values fro $_GET["url"] and if I request localhost/test_mvc/public/index/greet/name the value that shows is /public/index/greet/name
How can I solve it to get the value index/greet/name?
Change your rule to this:
Options -MultiViews
RewriteEngine On
RewriteBase /test_mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^public/(.*)$ index.php?url=$1 [QSA,L,NC]
I'm having problems setting up my .htaccess file. In my web folder (in the root of my project) I have index.php . Now I have to go to mydomain.com/web/ to see my index.php .
I've added a .htacces file in my /web folder but it isn't working. This is the content of my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
What am I doing wrong?
You can have 2 .htaccess for this:
root .htaccess (a level above web):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!web/).*)$ web/$1 [NC,L]
/web/.htaccess:
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
Have you tried RewriteBase ?
RewriteBase /web/
This post can be also helpful
How does RewriteBase work in .htaccess
I want to convert the URL http://localhost/project1/mvc/public/content/1 to the URL http://localhost/content/1.
I have my .htaccess file placed in the public folder that removes the index.php in the URL.
Options -MultiViews
RewriteEngine On
RewriteBase /project1/mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
Here's my directory structure:
Project 1
---mvc
-----app
-----public
I need help in the creating .htaccess file for this. What is the syntax for modifying the URL and which folder/s should I put the .htaccess file/s?
Thanks
You can use this code in your DOCUMENT_ROOT/.htaccess file (above a directory level of mvc):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!/project1/mvc/public/).*) project1/mvc/public/$1 [L,NC]