Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用.htaccess从laravel中删除角度标签_Php_.htaccess_Laravel - Fatal编程技术网

Php 使用.htaccess从laravel中删除角度标签

Php 使用.htaccess从laravel中删除角度标签,php,.htaccess,laravel,Php,.htaccess,Laravel,我有codeigniter.htaccess文件,比如 <ifModule mod_rewrite.c> RewriteEngine on # allow social media crawlers to work by redirecting them to a server-rendered static version on the page RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterb

我有codeigniter.htaccess文件,比如

<ifModule mod_rewrite.c>
RewriteEngine on

# allow social media crawlers to work by redirecting them to a server-rendered static version on the page

RewriteCond %{HTTP_USER_AGENT} (facebookexternalhit/[0-9]|Twitterbot|Pinterest|Google.*snippet)
RewriteRule eventApp/(\d*)$ [P]


# Required to allow direct-linking of pages so they can be processed by Angular
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /eventApp/index.html [NC,L]

</ifModule>

重新启动发动机
#通过将社交媒体爬虫重定向到页面上服务器呈现的静态版本,允许社交媒体爬虫工作
重写cond%{HTTP_USER_AGENT}(facebookexternalhit/[0-9]| Twitterbot | Pinterest | Google.*代码段)
重写规则eventApp/(\d*)$[P]
#需要允许页面的直接链接,以便可以通过
RewriteCond%{REQUEST_FILENAME}-s[或]
RewriteCond%{REQUEST_FILENAME}-l[或]
RewriteCond%{REQUEST_FILENAME}-d
重写规则^.*$-[NC,L]
重写规则^(.*)/eventApp/index.html[NC,L]

但是我想从laravel中删除hashtag。

要从URL片段中删除hash,只需将angular设置为不添加,无需修改
.htaccess
文件。因此,这个答案为所提出的问题提出了一个更为清晰的解决方案

在角度基准模块中,通常在其中定义路线

angular.module('app', [])
    .config([
        '$routeProvider', 
        '$locationProvider', 
        function($routeProvider, $locationProvider) {
            // Hashtags no longer appear with this
            $locationProvider.html5Mode(true);

            // Route definitions below
        }]);
您还需要在HTML视图中设置
base
标题元素。angular使用它来确定构建URL时应该使用的路径。本例将使用根目录

<!doctype html>
<head>
    <title>Laravel</title>
    <base href="/" />
</head>

拉维尔

是否没有其他方法可以将基准指定为角度?使用该标记会破坏正常的片段链接,例如,URL路径为
/foo/
的页面上的
不会转到
/foo/#bar
。是的,这是正确的,但如果我可以刷新我的页面,它将显示错误,如在laravel中找不到页面。所以我认为我们需要为它设置.htaccess。因此,它在CI中的工作方式与上述规则相同,我不会将其设置为laravel。如果您知道,请让我们知道。您可以在laravel捕捉路线,您不需要对此进行
.htaccess
修改<代码>路由::any({path?}),function(){return view(“index”);})->where(“path”,“+”注意路线末端的位置,这将匹配所有未定义的路线,并返回角度应用程序。