dqdmvg7332 2015-08-13 11:01
浏览 60

如果页面名称与子文件夹的名称相同,则显示页面

So, I have 4 folders in my public folder: js, css, images, fonts (yes, i should put all in one folder). I also have a route which is pointing to an /images page. The problem is, when I open the images page, it throws a 404 error. Are there any solutions for this, or I have to rename the folder or the page. (The page names will be dynamic, so if the user creates a page named "anotherPage" it will be /anotherpage.)

routes.php

Route::get('/{pagename?}', 'PageController@index');

.htaccess

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

  • 写回答

2条回答 默认 最新

  • doukong5394 2015-08-13 11:26
    关注

    If i understand your question correctly.

    You can have same name as your folders BUT, if a file with name upload exist within the folder upload (upload/upload.ext). It will always direct to folder not the file and try to get upload/index.ext.

    This is a default yet confusing behavior which can lead to ambiguous results. Never use same folder names and files.

    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法