I'm using laravel routes, and I have a problem with URL
for example
https://laracasts.com/discuss. - URL has a double
https://laracasts.com/index.php/discuss
how to fix it?enter image description here
If it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Now you should be able to access the website without the "/public/index.php/" part.
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Related
I have a laravel app: https://laravel-app.com
I want to serve custom pages from a folder on the same domain https:laravel-app.com/player/player.php
I have set the .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /player/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /player/player.php [L]
</IfModule>
But when I try and navigate to that page by using this direct url: https:laravel-app.com/player/player.php
I get the laravel routing error: sorry, the page could not be found
Can someone explain how to get around this?
Anything you want accessible you can put in the public folder of your application, which should be the DocRoot/WebRoot. You won't need any special rewriting or rules as it will be an existing file so the server will serve it fine.
I have my website hosted at https://www.webdomain.com/
The hosted website at the above domain IS NOT CODEIGNITER
On the server, at the location my_username/public_html/www/myproject, a Codeigniter application is hosted.
Meaning, to access a controller and its function in myproject application.
I use the following URL
https://webdomain.com/myproject/controller/function
As you may have already noticed, myproject is the root folder of the Codeigniter application
I've been trying to remove myproject from the URL, but with no luck.
I've gone through several questions on stack overflow, but as I figured it out, all of those questions refer to project directories, that are not necessarily application root directory. In my case, I want to remove the name of the root directory myproject from the URL.
This is my .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
Try this:
RewriteRule ^myproject/(.*)$ $1 [R]
This need to be in the root folder, I strongly recommend you go with #vivek_23 suggestion in the comment.
Have you try to set route in route.php file?
$route['controller/function'] = 'myproject/controller/function';
Try with .htaccess. I mainly used this on the localhost machine. This .htaccess file should be in the root of myproject folder. Here is the documentation for more information https://httpd.apache.org/docs/current/howto/htaccess.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myproject/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
Hope this will help to out :)
I have an issue with my .htaccess.
Let's say that my app folder are:
/APP/
/CONTENT/
/UPLOADS/
/ASSETS/
And I have a .htaccess file that point all requests to my index.php, and the index php there is an included file called router.php that manage my roots:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\s\S]*)$ index.php?url=$0 [QSA,L]
What i would want to do right now is to point APP and CONTENT folder also to the .htaccess and like that, i can display my custom 404 error page.
I have a php file which is home.php
my url on localhost is
http://localhost:8888/photo/home.php
I want to remove .php from the url
so i create .htaccess file
RewriteEngine On
RewriteRule ^home?$ home.php
but i keep getting this error
The requested URL /photo/home was not found on this server.
First of all, ensure your .htaccess file is in the base directory of your project. Next, follow these htaccess rules to set up your redirect.
The .htaccess solution you might be looking for is:
RewriteEngine On
#Neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^photo/home$ photo/home.php [QSA,L]
Try it like this, in your photo directory.
RewriteEngine On
# neither a file nor a directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^home$ home.php [QSA,L]
I got this problem when I put the .htaccess code in the root .htaccess. It works when I create a new .htaccess in the subdomain folder on the same level with public_html folder and fill it with the RewriteRule needed
Here's my problem:
I have wordpress installed in the root folder
I created a folder named demo, also in the root folder
Now, this setup works, I can access php files inside the demo folder just fine (e.g. http://example.com/demo/test.php) as well as text files
The problem is when I try to access .xlsx files inside thedemo` folder the 404 page shows up
I'm not really sure if the problem is the .htaccess but here it is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I believe the best secure way to put files in wp-content to be able to easily access them