So I have tried both versions of the .htaccess, the one that comes with it in project creation and the one in the documentation. I am currently using the one in the documentation:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I have my virtualhost set up like so:
<VirtualHost *:80>
ServerAdmin <my email>
ServerName projectflyer.<my domain>.com
DocumentRoot /var/www/html/projects/project-flyer/public
DirectoryIndex index.php
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
However when I go to projectflyer.mydomain.com/some/route I get back a 404. Any ideas? Yes I can go to the base url just fine.
I solved this by adding this to my virtualhost .conf file:
<Directory /path/to/your/install/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Thanks to http://laravel.io/forum/09-15-2015-removing-indexphp-from-url-laravel-5116 for the answer
Related
I am having issues redirecting to index.php in my slim app with .htaccess file.
Routes work if I add the index.php at the end of the URL
So slimapp.dev/hello/myname gets error
Not Found The requested URL /hello/myname was not found on this server.
while slimapp.dev/index.php/hello/myname works
Here is my .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index.php [QSA,L]
I am using Apache 2 on Ubuntu 18.04
File structure
public_html
|_index.php
|_ vendor
|_.htaccess
virtualHost 000-default.conf
<VirtualHost *:80>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
If I use the php -S localhost:3000 it works as expected but if I use the Apache web server, I most add the index.php to the end of the URL to make it work. Thanks
You are doing wrong.This is quite simple with just two lines of code:
RewriteEngine On
RewriteRule ^myname/(.*)$ /$1 [L]
I currently using CodeIgniter 3. It is working on my laptop.
But when I upload it to my Centos 6.9 server... I encounter an error.
I already check the mod_rewrite is loaded.
I want it to be like this URL/controller/method (no index.php after URL)
It shows me a 404 when i try to login which redirect me to this URL/gate/login
I also set this....
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
My htaccess on /var/www/html/calllist
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /calllist/index.php?/$1 [L]
</IfModule>
My httpd.conf
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster#xxxx.com
DocumentRoot /var/www/html/calllist
ServerName www.xxxx.com
ErrorLog /var/www/html/calllist/error_log
CustomLog /var/www/html/calllist/requests.log common
</VirtualHost>
i solved the issue.
apparently on httpd.conf, there is another line i need to set to 'All'.
and i added this to my virtual host
<Directory "/var/www/html/calllist">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I have a test website on my ubuntu computer, the URL is: mysite.test. I have marketing pages: http://mysite.test/hello.php, http://mysite.test/goodbye.php, etc.
I also have wildcard subdomains: http://user1.mysite.test/page1.php, http://user2.mysite.test/page.1php, etc.
I'd like all pages to be accessible without adding the ".php" extension (marketing site, and subdomains). I've modified my .htaccess files, but its not working and I can't figure out why. mod_rewrite is enabled and working (the "Remove www" rule below works).
#/var/www/mysite.test/public_html/.htaccess
RewriteEngine On
#Remove www - this works
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC]
#Not need .php extension - this does not work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php
Removing the first rule ("Remove www") doesn't make it start working.
When I go to http://mysite.test/hello I get a 404 Not Found error. Going to http://mysite.test/hello.php loads just fine.
When I go to http://user1.mysite.test/page1 I get a 404 Not Found error. Going to http://user1.mysite.test/page1.php loads just fine.
My Virtual Hosts file looks like this:
#/etc/apache2/sites-available/mysite.test.conf
<VirtualHost *:80>
ServerName www.mysite.test
ServerAlias mysite.test
ServerAdmin fake#gmail.com
DocumentRoot /var/www/mysite.test/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/mysite.test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName wildcard.mysite.test
ServerAlias *.mysite.test
DocumentRoot /var/www/mysite.test/public_html/app
<Directory /var/www/mysite.test/public_html/app>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
What am I missing? Thank you.
I'm not sure I can give you a helpful solution to your issue, but I have a similar piece of code that works:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.|/]+)$ $1.php [NC,L]
this sets that if it is not a file, and if it doesn't contain a . (such as an image reference.jpg then it has .php appended to the filename.
This works perfectly for me.
I wanted to isntall laravel in a sub directory inside my dev machine http://dev-machine/applis/main/laravel
My default document root is F:/data/web
My .htaccess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /applis/main/laravel
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
My httpd.conf file has below code
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "applis/main/laravel/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I have also tried the belwo virtual host config
<VirtualHost *:80>
ServerName http://dev-machine/applis/main/laravel/public
Alias /laravel applis/main/laravel/public
DocumentRoot F:/data/web/applis/main/laravel/public
<Directory "/applis/main/laravel/public">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But stil I am unable to access the app via
http://dev-machine/applis/main/laravel/public
I am getting he below error
Not Found
The requested URL /applis/main/laravel/public/ was not found on this server.
After adding the virtual host when it is not even loading the index.php file when I try loading it directly via http://dev-machine/applis/main/laravel/public/index.php
I'm using Ubuntu 14.04. I have installed LAMP, Composer and I installed Laravel. I created virtual domain (laravel.dev) and it works, but only when I'm using for simple laravel.dev/index.php/auth/login. When I use laravel.dev/css I have laravel/public/css folder. I have default .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
AllowOverride All
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And my *.conf file:
<VirtualHost *:80>
ServerName laravel.dev
ServerAdmin webmaster#laravel.dev
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
How can I fix it?
My main page:
http://i.imgur.com/AxQjV9q.png
I fall this problem.I solved it using apache mod rewrite enable.For that follow this
http://www.kingpabel.com/apache-mod_rewrite/
Currently, your virtualhost doesn't allow overriding the rewriting settings in the .htaccess of your project.
You should add the following lines to your .conf file, in the virtualhost :
<Directory "/var/www/laravel/public">
AllowOverride All
</Directory>
Which would result in the following file :
<VirtualHost *:80>
ServerName laravel.dev
ServerAdmin webmaster#laravel.dev
DocumentRoot /var/www/laravel/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/laravel/public">
AllowOverride All
</Directory>
</VirtualHost>